一杯清酒邀明月
天下本无事,庸人扰之而烦耳。

效果图片如下:

代码如下:

 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 }

 

posted on 2021-03-25 14:06  一杯清酒邀明月  阅读(654)  评论(0编辑  收藏  举报