I am trying to create tool bar at QdockWidget. But the icons in tool bar are not getting placed at proper position. They should come just below the title.
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);
How to set tool bar at the top?
Maybe you should try adding a layout to the widget "this",then put "placeholder" widget to the layout.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.