QT QDockWidget 重疊方法

來源:互聯網
上載者:User

主要通過如下紅色代碼的方法實現

 

片如下:

 

代碼如下:

 

void MainWindow::createDockWindows()

{

    QDockWidget *dock = new QDockWidget(tr("Customers"), this);

    dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);

    customerList = new QListWidget(dock);

    customerList->addItems(QStringList()

            << "John Doe, Harmony Enterprises, 12 Lakeside, Ambleton"

            << "Jane Doe, Memorabilia, 23 Watersedge, Beaton"

            << "Tammy Shea, Tiblanka, 38 Sea Views, Carlton"

            << "Tim Sheen, Caraba Gifts, 48 Ocean Way, Deal"

            << "Sol Harvey, Chicos Coffee, 53 New Springs, Eccleston"

            << "Sally Hobart, Tiroli Tea, 67 Long River, Fedula");

    dock->setWidget(customerList);

    addDockWidget(Qt::RightDockWidgetArea, dock);

    viewMenu->addAction(dock->toggleViewAction());

 

    QDockWidget * dock1 = new QDockWidget(tr("Paragraphs"), this);

    paragraphsList = new QListWidget(dock1);

    paragraphsList->addItems(QStringList()

            << "1"

            << "2 "

            << "4"

            << "5"

            << "6"

            << "7");

    dock1->setWidget(paragraphsList);

    addDockWidget(Qt::RightDockWidgetArea, dock1);

    viewMenu->addAction(dock1->toggleViewAction());

 

    tabifyDockWidget(dock, dock1);

    QDockWidget *dock2 = new QDockWidget(tr("Paragraphs"), this);

    addDockWidget(Qt::RightDockWidgetArea, dock2);

    viewMenu->addAction(dock2->toggleViewAction());

 

    tabifyDockWidget(dock1, dock2);

    QDockWidget *dock3 = new QDockWidget(tr("whb"), this);

    addDockWidget(Qt::RightDockWidgetArea, dock3);

    viewMenu->addAction(dock3->toggleViewAction());


    tabifyDockWidget(dock2, dock3);

    dock->raise();

 

    connect(customerList, SIGNAL(currentTextChanged(QString)),

            this, SLOT(insertCustomer(QString)));

    connect(paragraphsList, SIGNAL(currentTextChanged(QString)),

            this, SLOT(addParagraph(QString)));

}

 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.