[英]How to add tool bar at the top in QDockWidget?
我正在嘗試在 QdockWidget 上創建工具欄。 但是工具欄中的圖標沒有放置在正確的 position。它們應該位於標題下方。
QWidget* placeholder = new QWidget();
QBoxLayout* toolLayout = new QBoxLayout(QBoxLayout::LeftToRight,placeholder);
toolLayout->setContentsMargins(0, 0, 0, 0);
auto toolbar = new QToolBar;
toolLayout->addWidget(toolbar);
const QIcon newIcon = QIcon::fromTheme("document-new", QIcon(":/img/copy1.png"));
QAction* zoomIn = new QAction(newIcon, tr("&Zoom In"), this);
const QIcon newIcon1 = QIcon::fromTheme("document-new", QIcon(":/img/cut1.png"));
QAction* zoomOut = new QAction(newIcon1, tr("&Zoom Out"), this);
toolbar->addAction(zoomIn);
toolbar->addAction(zoomOut);
setWidget(placeholder);
如何設置工具欄在頂部?
也許您應該嘗試向小部件“this”添加布局,然后將“placeholder”小部件添加到布局中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.