DtkWidget
DTK Widget module
载入中...
搜索中...
未找到
Dtk::Widget::DMainWindow类 参考

The DMainWindow class provides a main application window. 更多...

类 Dtk::Widget::DMainWindow 继承关系图:

Public 槽

void setWindowRadius (int windowRadius)
 DMainWindow::setWindowRadius 设定窗口的圆角 windowRadius 窗口的圆角值
 
void setBorderWidth (int borderWidth)
 DMainWindow::setBorderWidth 设定边框的宽度 borderWidth 边框的宽度
 
void setBorderColor (const QColor &borderColor)
 DMainWindow::setBorderColor 设定边框的颜色 borderColor 边框的颜色
 
void setShadowRadius (int shadowRadius)
 DMainWindow::setShadowRadius 设定阴影区域的圆角 shadowRadius 阴影区域圆角大小
 
void setShadowOffset (const QPoint &shadowOffset)
 DMainWindow::setShadowOffset 设定阴影区域的偏移距离 shadowOffset 阴影区域的偏移距离
 
void setShadowColor (const QColor &shadowColor)
 DMainWindow::setShadowColor 设定阴影的颜色 shadowColor 阴影的颜色
 
void setClipPath (const QPainterPath &clipPath)
 DMainWindow::setClipPath 设定裁剪路径 clipPath 裁剪的路径
 
void setFrameMask (const QRegion &frameMask)
 DMainWindow::setFrameMask 设定边框的mask区域 frameMask mask区域
 
void setTranslucentBackground (bool translucentBackground)
 DMainWindow::setTranslucentBackground 设定时候擦除背景 translucentBackground true擦除背景 false不擦除背景
 
void setEnableSystemResize (bool enableSystemResize)
 DMainWindow::setEnableSystemResize 设定是否允许系统调整窗口大小 enableSystemResize true允许系统调整 false不允许系统调整
 
void setEnableSystemMove (bool enableSystemMove)
 DMainWindow::setEnableSystemMove 设定时候允许系统移动窗口 enableSystemMove true允许移动 false不允许移动
 
void setEnableBlurWindow (bool enableBlurWindow)
 DMainWindow::setEnableBlurWindow 设置窗口模糊效果 开启此功能请设置setAttribute(Qt::WA_TranslucentBackground) enableBlurWindow true开启模糊效果 false关闭模糊效果
 
void setAutoInputMaskByClipPath (bool autoInputMaskByClipPath)
 通过裁剪区域自动设定mask.
 
void sendMessage (const QIcon &icon, const QString &message)
 发送浮动消息.
 
void sendMessage (DFloatingMessage *message)
 发送浮动消息.
 
void setTitlebarShadowEnabled (bool titlebarShadowEnabled)
 

信号

void windowRadiusChanged ()
 
void borderWidthChanged ()
 
void borderColorChanged ()
 
void shadowRadiusChanged ()
 
void shadowOffsetChanged ()
 
void shadowColorChanged ()
 
void clipPathChanged ()
 
void frameMaskChanged ()
 
void frameMarginsChanged ()
 
void translucentBackgroundChanged ()
 
void enableSystemResizeChanged ()
 
void enableSystemMoveChanged ()
 
void enableBlurWindowChanged ()
 
void autoInputMaskByClipPathChanged ()
 
void sidebarVisbleChanged (bool visible)
 
void sidebarExpanedChanged (bool expaned)
 

Public 成员函数

 DMainWindow (QWidget *parent=0)
 DMainWindow::DMainWindow constructs an instance of DMainWindow parent is passed to QMainWindow construtor.
 
DTitlebartitlebar () const
 DMainWindow::titlebar
 
void setSidebarWidget (QWidget *widget)
 
QWidget * sidebarWidget ()
 
int sidebarWidth () const
 
void setSidebarWidth (int width)
 
bool sidebarVisible () const
 
void setSidebarVisible (bool visible)
 
bool sidebarExpanded () const
 
void setSidebarExpanded (bool expended)
 
bool isDXcbWindow () const
 DMainWindow::isDXcbWindow
 
int windowRadius () const
 
int borderWidth () const
 
QColor borderColor () const
 
int shadowRadius () const
 
QPoint shadowOffset () const
 
QColor shadowColor () const
 
QPainterPath clipPath () const
 
QRegion frameMask () const
 
QMargins frameMargins () const
 
bool translucentBackground () const
 
bool enableSystemResize () const
 DMainWindow::enableSystemResize
 
bool enableSystemMove () const
 
bool enableBlurWindow () const
 
bool autoInputMaskByClipPath () const
 
bool titlebarShadowIsEnabled () const
 

Protected 成员函数

 DMainWindow (DMainWindowPrivate &dd, QWidget *parent=0)
 
void mouseMoveEvent (QMouseEvent *event) override
 
void resizeEvent (QResizeEvent *event) override
 
void changeEvent (QEvent *event) override
 

属性

int windowRadius
 This property holds the radius of the main window.
 
int borderWidth
 This property holds the width of the main window's border.
 
QColor borderColor
 This property holds the color of the main window's border.
 
int shadowRadius
 This property holds the shadow radius of the main widnow.
 
QPoint shadowOffset
 This property holds the offset applied on the window shadow.
 
QColor shadowColor
 This property holds the color of the window shadow.
 
QPainterPath clipPath
 This property holds the custom QPainterPath to be used to clip the window.
 
QRegion frameMask
 This property holds the mask to be applied on the window.
 
QMargins frameMargins
 
bool translucentBackground
 This property holds whether the window has translucent background.
 
bool enableSystemResize
 此属性保留是否可以由用户调整窗口大小。此属性的默认值是正确的。您可以将此属性设置为false并实现此属性的调整窗口大小
 
bool enableSystemMove
 This property holds whether the window can be moved by the user.
 
bool enableBlurWindow
 This property holds whether the window background is blurred.
 
bool autoInputMaskByClipPath
 This property holds whether the user input is masked by the clip path.
 
bool titlebarShadowEnabled
 titleBar阴影属性.
 

详细描述

The DMainWindow class provides a main application window.

DMainWindow类提供了一个主应用程序窗口,主窗口为构建应用程序的用户提供了一个框架 界面。与Qmainwindow相比,DmainWindow具有自己的布局它只有标题栏和内容区域,更简单。 开发人员可以提供自定义的标题栏和内容,以使应用功能丰富。

\inmodule dtkwidget

A main window provides a framework for building an application's user interface. DMainWindow has its own layout compared to QMainWindow, it has only title bar and content area, simpler and cleaner.

Developers can provide customized title bar and content to make the application rich functional.

概述

DMainWindow类提供了一个主应用程序窗口,主窗口为构建应用程序的用户提供了一个框架 界面。与Qmainwindow相比,DmainWindow具有自己的布局它只有标题栏和内容区域,更简单。 开发人员可以提供自定义的标题栏和内容,以使应用功能丰富。

使用如下代码显示一个最简单的DMainWindow窗口:

CMakeLists.txt

cmake_minimum_required(VERSION 3.1.0) # 指定cmake最低版本
project(example1 VERSION 1.0.0 LANGUAGES CXX) # 指定项目名称, 版本, 语言 cxx就是c++
set(CMAKE_CXX_STANDARD 11) # 指定c++标准
set(CMAKE_CXX_STANDARD_REQUIRED ON) # 指定c++标准要求,至少为11以上
# set(target example1) # 指定目标名称
set(CMAKE_AUTOMOC ON) # support qt moc # 支持qt moc
set(CMAKE_AUTORCC ON) # support qt resource file # 支持qt资源文件
set(CMAKE_AUTOUIC ON) # support qt ui file # 支持qt ui文件(非必须)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # suppot clangd 支持clangd
if (CMAKE_VERSION VERSION_LESS "3.7.0") # 如果cmake版本小于3.7.0
set(CMAKE_INCLUDE_CURRENT_DIR ON) # 设置包含当前目录
endif()
find_package(Qt5 COMPONENTS Widgets Core REQUIRED) # 寻找Qt5组件Widgets
find_package(Qt5 COMPONENTS Gui REQUIRED) # 寻找Qt5组件Gui
find_package(Dtk COMPONENTS Widget REQUIRED) # 寻找Dtk组件Widget
find_package(Dtk COMPONENTS Core REQUIRED) # 寻找Dtk组件Core
find_package(Dtk COMPONENTS Gui REQUIRED) # 寻找Dtk组件Gui
add_executable(example1 # 添加可执行文件
main.cpp
)
target_link_libraries(example1 PRIVATE Qt5::Widgets Qt5::Gui Qt5::Core dtkgui dtkcore dtkwidget) # 链接库

main.cpp

#include <DApplication> //应用程序依赖
#include <DMainWindow> //主窗口依赖
#include <DApplicationSettings> //进行应用设置的依赖
DWIDGET_USE_NAMESPACE; //使用DTK widget命名空间
int main(int argc, char *argv[]){
DApplication app(argc, argv); //设置一个应用
app.setApplicationName("这是应用名称"); //设置应用名称
app.setOrganizationName("deepin"); //设置关于信息中的系统信息
app.setApplicationVersion("2.0"); //设置关于信息中的版本号
DApplicationSettings as;
Q_UNUSED(as) //设置记住应用主题
DMainWindow dwm; //使用DMainWindow类实例化一个窗口
dwm.resize(400,250); //可使用resize()对窗口大小进行调整
dwm.show(); //显示这个窗口
return app.exec(); //运行应用
}
DApplication 是 DTK 中用于替换 QCoreApplication 相关功能实现的类.
Definition dapplication.h:33
The DMainWindow class provides a main application window.
Definition dmainwindow.h:20

以上例子运行结果如下:

example

点击菜单栏About弹出关于对话框,关于对话框具体参见daboutdialog,效果如下

example2

成员函数说明

◆ enableSystemResize()

bool Dtk::Widget::DMainWindow::enableSystemResize ( ) const

DMainWindow::enableSystemResize

返回
This property holds whether the window can be resized by the user.

The default value of this property is true.

You can set this property to false and implement the resize polizy of this window by you self.

◆ isDXcbWindow()

DMainWindow::isDXcbWindow ( ) const

DMainWindow::isDXcbWindow

支持许多功能,例如背景模糊和窗口剪裁,仅当窗口使用DXCB QT平台插件时。

返回
Whether this window is dxcb backended.

Many features like blurred background and window clipping are supported only if the window is using the dxcb Qt platform plugin.

返回
该窗口是否为dxcb backended

◆ sendMessage [1/2]

void Dtk::Widget::DMainWindow::sendMessage ( const QIcon &  icon,
const QString &  message 
)
slot

发送浮动消息.

icon 消息展示图标 message 消息内容

◆ sendMessage [2/2]

void Dtk::Widget::DMainWindow::sendMessage ( DFloatingMessage message)
slot

发送浮动消息.

message DFloatingMessage消息

◆ setAutoInputMaskByClipPath

void DMainWindow::setAutoInputMaskByClipPath ( bool  autoInputMaskByClipPath)
slot

通过裁剪区域自动设定mask.

autoInputMaskByClipPath true自动设定 false不自动设定

参见
autoInputMaskByClipPath true自动设定 false不自动设定

◆ setBorderColor

void DMainWindow::setBorderColor ( const QColor &  borderColor)
slot

DMainWindow::setBorderColor 设定边框的颜色 borderColor 边框的颜色

设定边框的颜色

参见
borderColor 边框的颜色

◆ setBorderWidth

void DMainWindow::setBorderWidth ( int  borderWidth)
slot

DMainWindow::setBorderWidth 设定边框的宽度 borderWidth 边框的宽度

设定边框的宽度

参见
borderWidth 边框的宽度

◆ setClipPath

void DMainWindow::setClipPath ( const QPainterPath &  clipPath)
slot

DMainWindow::setClipPath 设定裁剪路径 clipPath 裁剪的路径

设定裁剪路径

参见
clipPath 裁剪的路径

◆ setEnableSystemMove

void DMainWindow::setEnableSystemMove ( bool  enableSystemMove)
slot

DMainWindow::setEnableSystemMove 设定时候允许系统移动窗口 enableSystemMove true允许移动 false不允许移动

设定时候允许系统移动窗口

参见
enableSystemMove true允许移动 false不允许移动

◆ setFrameMask

void DMainWindow::setFrameMask ( const QRegion &  frameMask)
slot

DMainWindow::setFrameMask 设定边框的mask区域 frameMask mask区域

设定边框的mask区域

参见
frameMask mask区域

◆ setShadowOffset

void DMainWindow::setShadowOffset ( const QPoint &  shadowOffset)
slot

DMainWindow::setShadowOffset 设定阴影区域的偏移距离 shadowOffset 阴影区域的偏移距离

设定阴影区域的偏移距离

参见
shadowOffset 阴影区域的偏移距离

◆ setShadowRadius

void DMainWindow::setShadowRadius ( int  shadowRadius)
slot

DMainWindow::setShadowRadius 设定阴影区域的圆角 shadowRadius 阴影区域圆角大小

设定阴影区域的圆角

参见
shadowRadius 阴影区域圆角大小

◆ setTranslucentBackground

void DMainWindow::setTranslucentBackground ( bool  translucentBackground)
slot

DMainWindow::setTranslucentBackground 设定时候擦除背景 translucentBackground true擦除背景 false不擦除背景

设定时候擦除背景

参见
translucentBackground true擦除背景 false不擦除背景

◆ titlebar()

DMainWindow::titlebar ( ) const

DMainWindow::titlebar

为主窗口设置titlebar

返回
a DTitlebar instance used by the main window.
主窗口使用的dtitlebar实例

属性说明

◆ autoInputMaskByClipPath

DMainWindow::autoInputMaskByClipPath
readwrite

This property holds whether the user input is masked by the clip path.

此属性是否将用户输入是否被剪辑路径掩盖,此属性的默认值是true

Sometimes you may want to handle events happening in the areas that are visually clipped by the setting DMainWindow::clipPath.

The default value of this property is true.

◆ borderColor

DMainWindow::borderColor
readwrite

This property holds the color of the main window's border.

此属性具有主窗口边框的颜色

◆ borderWidth

DMainWindow::borderWidth
readwrite

This property holds the width of the main window's border.

该属性拥有主窗边框的宽度

◆ clipPath

DMainWindow::clipPath
readwrite

This property holds the custom QPainterPath to be used to clip the window.

此属性保留了自定义QPainterPath来夹住窗口。默认DMAINWINDOW被剪辑为一个 转角矩形,但是您可以提供自定义的QPainterPath来执行自定义形状的窗口

By default DMainWindow is clipped as a corner-rounded rectangle, but you can supply a custom QPainterPath to do custom shaped window.

参见
DMainWindow::frameMask
DMainWindow::frameMask

◆ enableBlurWindow

DMainWindow::enableBlurWindow
readwrite

This property holds whether the window background is blurred.

该属性是否有窗口背景是否模糊

◆ enableSystemMove

DMainWindow::enableSystemMove
readwrite

This property holds whether the window can be moved by the user.

此属性保留用户是否可以移动窗口。此属性的默认值为true。您可以将此属性设置为false,并选择有效的区域拖动和移动

The default value of this property is true.

You can set this property to false and choose the effective area to drag and move.

◆ frameMask

DMainWindow::frameMask
readwrite

This property holds the mask to be applied on the window.

此属性将蒙版贴在窗口上。对于更好的剪辑质量,例如抗质量,请改用属性dmainwindow :: clippath

For better clip quality, for example antialiasing, use property DMainWindow::clipPath instead.

◆ shadowColor

DMainWindow::shadowColor
readwrite

This property holds the color of the window shadow.

此属性拥有窗户阴影的颜色

◆ shadowOffset

DMainWindow::shadowOffset
readwrite

This property holds the offset applied on the window shadow.

此属性保存在窗户阴影上应用的偏移量

◆ shadowRadius

DMainWindow::shadowRadius
readwrite

This property holds the shadow radius of the main widnow.

该属性拥有主窗口的阴影半径

◆ titlebarShadowEnabled

DMainWindow::titlebarShadowEnabled
readwrite

titleBar阴影属性.

titleBar阴影属性,用于设置或者判断是否设置titleBar阴影属性

用于设置或者判断是否设置titleBar阴影属性.

DMainWindow::setWindowRadius 设定窗口的圆角

参见
windowRadius 窗口的圆角值

◆ translucentBackground

DMainWindow::translucentBackground
readwrite

This property holds whether the window has translucent background.

该属性属于窗口是否具有半透明背景

◆ windowRadius

DMainWindow::windowRadius
readwrite

This property holds the radius of the main window.

该属性保持主窗口的半径


该类的文档由以下文件生成: