码迷,mamicode.com
首页 > 其他好文 > 详细

《Qt5 开发与实例(第三版)》学习笔记(七)

时间:2018-01-26 22:59:45      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:depend   ext   ali   table   setw   窗口   detach   moved   lld   

 1 // 3.2 停靠窗口 QDockWidget类
 2 setFeatures()
 3 setAllowedAreas()
 4 setWidget()
 5 addDockWidget()
 6 
 7 //dockwindows.cpp
 8 #include "dockwindows.h"
 9 #include <QTextEdit>
10 #include <QDockWidget>
11 DockWindows::DockWindows(QWidget *parent)
12     : QMainWindow(parent)
13 {
14     setWindowTitle(tr("DockWindows"));
15     QTextEdit *te=new QTextEdit(this);//设置为主窗口
16     te->setText(tr("Main Window"));
17     te->setAlignment(Qt::AlignCenter);
18     setCentralWidget(te);//设置为主窗口的中央窗体
19 
20     QDockWidget *dock= new QDockWidget(tr("DockWindow1"),this);
21     dock->setFeatures(QDockWidget::DockWidgetMovable);
22     dock->setAllowedAreas(Qt::LeftDockWidgetArea|Qt::RightDockWidgetArea);
23     QTextEdit *te1=new QTextEdit();
24     te1->setText(tr("Windows1  This dock widget can be moved between docks by the user"));
25     dock->setWidget(te1);//将控件加入dock停靠窗体
26     addDockWidget(Qt::RightDockWidgetArea,dock);//在MainWindow中加入此停靠窗体
27 
28     dock= new QDockWidget(tr("DockWindow2"),this);
29     dock->setFeatures(QDockWidget::DockWidgetClosable|QDockWidget::DockWidgetFloatable);
30     QTextEdit *te2 = new QTextEdit();
31     te2->setText(tr("Windows2   The dock widget can be detached from the main window,and floated as an independent window, and can be closed"));
32     dock->setWidget(te2);
33     addDockWidget(Qt::RightDockWidgetArea,dock);
34 
35     dock=new QDockWidget(tr("DockWindow3"),this);
36     dock->setFeatures(QDockWidget::AllDockWidgetFeatures);
37     QTextEdit *te3=new QTextEdit();
38     te3->setText(tr("Windows3   The dock widget can be closed, moved, and floated"));
39     dock->setWidget(te3);
40     addDockWidget(Qt::RightDockWidgetArea,dock);
41 }
42 
43 DockWindows::~DockWindows()
44 {
45 
46 }

 

《Qt5 开发与实例(第三版)》学习笔记(七)

标签:depend   ext   ali   table   setw   窗口   detach   moved   lld   

原文地址:https://www.cnblogs.com/justsong/p/8361197.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!