Quantcast
Channel: Jobs
Viewing all articles
Browse latest Browse all 18427

Problem aligning widgets in QVBoxLayout

$
0
0
I have a MainWindow with a centralWidget that contains a main QHBoxLayout. This main layout in turn contains a QHBoxLayout and, to the right of this, a QVBoxLayout. The QVBoxLayout contains three QLabel widgets that I have added using vboxlayout->addWidget(aWidget, 0, Qt::AlignHCenter). Problem is that no matter what alignment flags I pass to addWidget my labels always end up aligned to the left of the layout. Abridged code: MainWindow::MainWindow(QWidget *parent)     : QMainWindow(parent) {     QWidget centralWidget = new QWidget;       centralLayout = new QHBoxLayout;       aclockLayout = new QHBoxLayout;     aclockLayout->addWidget(aclock, 0, Qt::AlignCenter);       counterLayout = new QVBoxLayout;     counterlayout->addWidget(vbclock, 0, Qt::AlignHCenter);     counterlayout->addWidget(dtdisplay, 0 Qt::AlignHCenter);     counterLayout->addWidget(tzdisplay, 0, Qt::AlignHCenter);       centralLayout->addLayout(aclockLayout);     centralLayout->addLayout(counterLayout);     centralWidget->setLayout(centralLayout);     setCentralWidget(centralWidget); } All I want is for my three widgets to be aligned on the vertical center line of the QVBoxLayout. What am I missing here?

Viewing all articles
Browse latest Browse all 18427

Trending Articles