Based upon your screenshot it looks like the column is completely removed when you remove the QTextWidget
. You can try experimenting with setting the visibility of the QTextWidget
to false rather than removing it.
text1->setVisible( false );
Although based upon the QGridLayout doc this may have the same result.
Or when you remove the QTextEdit
replace it with a QSpacerItem so the column isn't completely remove.
If that still doesn't work I would next try changing your align of the QPushButton
to Qt::AlignLeft
.
layout->addWidget(button1,0,0,1,1, Qt::AlignLeft);
If you're not happy with that I would try using a QHBoxLayout rather than the QGridLayout
to layout the items horizontally. Or you could always use the QHBoxLayout
within the first row/column of the QGridLayout
, it's ultimately up to your future use cases.
For example:
QHBoxLayout* hLayout = new QHBoxLayout();
hLayout->addWidget( button1, 0, Qt::AlignLeft );
hLayout->addWidget( text1, 0, Qt::AlignLeft );
qGridLayout->addLayout ( hLayout, 0, 0, Qt::AlignLeft );
Again with the QHBoxLayout
and QGridLayout
(might no longer need to use the grid) you may have to play with the alignments to get the results you want. Something like this might work