Qt QDockWidget 重叠方法

效果图片如下:.

Qt QDockWidget 重叠方法_第1张图片

代码如下:

 1 void MainWindow::createDockWindows()
 2 
 3 {
 4     QDockWidget *dock = new QDockWidget(tr("Customers"), this);
 5 
 6     dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
 7 
 8     customerList = new QListWidget(dock);
 9 
10     customerList->addItems(QStringList()
11 
12             << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"
13 
14             << "Jane Doe, Memorabilia, 23 Watersedge, Beaton"
15 
16             << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"
17 
18             << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"
19 
20             << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"
21 
22             << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");
23 
24     dock->setWidget(customerList);
25 
26     addDockWidget(Qt::RightDockWidgetArea, dock);
27 
28     viewMenu->addAction(dock->toggleViewAction());
29 
30  
31 
32     QDockWidget * dock1 = new QDockWidget(tr("Paragraphs"), this);
33 
34     paragraphsList = new QListWidget(dock1);
35 
36     paragraphsList->addItems(QStringList()
37 
38             << "1"
39 
40             << "2 "
41 
42             << "4"
43 
44             << "5"
45 
46             << "6"
47 
48             << "7");
49 
50     dock1->setWidget(paragraphsList);
51 
52     addDockWidget(Qt::RightDockWidgetArea, dock1);
53 
54     viewMenu->addAction(dock1->toggleViewAction());
55 
56  
57 
58     tabifyDockWidget(dock, dock1);
59 
60     QDockWidget *dock2 = new QDockWidget(tr("Paragraphs"), this);
61 
62     addDockWidget(Qt::RightDockWidgetArea, dock2);
63 
64     viewMenu->addAction(dock2->toggleViewAction());
65 
66  
67 
68     tabifyDockWidget(dock1, dock2);
69 
70     QDockWidget *dock3 = new QDockWidget(tr("whb"), this);
71 
72     addDockWidget(Qt::RightDockWidgetArea, dock3);
73 
74     viewMenu->addAction(dock3->toggleViewAction());
75 
76 
77 
78     tabifyDockWidget(dock2, dock3);
79 
80     dock->raise();
81 
82  
83 
84     connect(customerList, SIGNAL(currentTextChanged(QString)),
85 
86             this, SLOT(insertCustomer(QString)));
87 
88     connect(paragraphsList, SIGNAL(currentTextChanged(QString)),
89 
90             this, SLOT(addParagraph(QString)));
91 
92 

本文福利,费领取Qt开发学习资料包、技术视频,内容包括(C++语言基础,Qt编程入门,QT信号与槽机制,QT界面开发-图像绘制,QT网络,QT数据库编程,QT项目实战,QT嵌入式开发,Quick模块,面试题等等)↓↓↓↓↓↓见下面↓↓文章底部点击费领取↓↓ 

你可能感兴趣的:(QT开发,qt,qt5,qt6,qt开发,qt教程)