Quantcast
Viewing all articles
Browse latest Browse all 18427

Strange widget positioning within a QToolBar

I have a problem with adding 3 widgets arranged in a QGridLayout. It works when I insert this into a QToolbar that I have defined with designer. I fails when this QToolbar is defined within the code. QToolBar* uiToolbar = new QToolBar(mainWindow);   QWidget *w = new QWidget; QGridLayout *gbox = new QGridLayout;   QComboBox* parametersCB = new QComboBox; QLabel* typeLabel = new QLabel("type"); QLabel* currentLabel = new QLabel(tr("Current parameters:"));   gbox->addWidget(currentLabel,0,0,1,2); gbox->addWidget(parametersCB,1,0); gbox->addWidget(typeLabel,1,1);   w->setLayout(gbox); uiToolbar->addWidget(w); mainWindow->addToolBar(Qt::TopToolBarArea, uiToolbar); I get this And after moving it one widget is on top of another one: The same with a pre existing toolbar: preExistingToolbar->addWidget(w); Perfect:

Viewing all articles
Browse latest Browse all 18427

Trending Articles