图1
图2
我的窗口启动起来时图1,我想让他一启动就是图2。也就是Paragraphs,Customers两个Dock窗口在一块叠加的类似标签页叠加的形式。
以下代码:
leaddocktest::leaddocktest()
: QMainWindow()
{
ui.setupUi(this);
createDockWindows();
}
leaddocktest::~leaddocktest()
{
}
void leaddocktest::createDockWindows()
{
viewMenu = menuBar()->addMenu(tr("&View"));
dock = new QDockWidget(tr("Customers"), this);
dock->setAllowedAreas(Qt::LeftDockWidgetArea| Qt::RightDockWidgetArea);
customerList = new QListWidget(dock);
customerList->addItems(QStringList()
<< "John Doe, Harmony Enterprises, Ambleton"
<< " Memorabilia,Beaton"
<< "Tammy Shea,38 Sea Views, Carlton"
<< "Tim Sheen, Caraba Gifts"
<< "Sol Harvey, Chicos Coffee"
<< "Sally Hobart, Tiroli Tea");
dock->setWidget(customerList);
addDockWidget(Qt::RightDockWidgetArea, dock);// LeftDockWidgetArea
viewMenu->addAction(dock->toggleViewAction());
dock = new QDockWidget(tr("Paragraphs"), this);
paragraphsList = new QListWidget(dock);
paragraphsList->addItems(QStringList()
<< "Thank you for your payment which we have received today."
<< "Your order has been dispatched and should be with you "
"within 28 days."
<< "We have dispatched those items that were in stock. The "
"rest of your order will be dispatched once all the "
"remaining items have arrived at our warehouse. No "
"additional shipping charges will be made."
<< "You made a small overpayment (less than $5) which we "
"will keep on account for you, or return at your request."
<< "You made a small underpayment (less than $1), but we have "
"sent your order anyway. We'll add this underpayment to "
"your next bill."
<< "Unfortunately you did not send enough money. Please remit "
"an additional $. Your order will be dispatched as soon as "
"the complete amount has been received."
<< "You made an overpayment (more than $5). Do you wish to "
"buy more items, or should we return the excess to you?");
dock->setWidget(paragraphsList);
addDockWidget(Qt::RightDockWidgetArea, dock);
viewMenu->addAction(dock->toggleViewAction());
connect(customerList, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(insertCustomer(const QString &)));
connect(paragraphsList, SIGNAL(currentTextChanged(const QString &)),
this, SLOT(addParagraph(const QString &)));
}