Note that there are some explanatory texts on larger screens.

plurals
  1. POQt problem with GUI application
    primarykey
    data
    text
    <p>I have a simple code in Qt, as below:</p> <pre><code>#include "mainwindow.h" #include &lt;QWidget&gt; #include &lt;QGroupBox&gt; #include &lt;QLabel&gt; #include &lt;QLineEdit&gt; #include &lt;QGridLayout&gt; #include &lt;QVBoxLayout&gt; class classA; class classB; MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { classA * objA = new classA(this); classB * objB = new classB(this); QVBoxLayout * mainLayout = new QVBoxLayout(this); setLayout(mainLayout); mainLayout-&gt;addWidget(objA); mainLayout-&gt;addWidget(objB); } MainWindow::~MainWindow(){} classA::classA(QWidget *parent) : QWidget(parent) { QGroupBox *grupa = new QGroupBox(tr("classA"),this); QLabel *labelA1 = new QLabel(tr("Label A1")); QLabel *labelA2 = new QLabel(tr("Label A2")); QLineEdit *LineEditA1 = new QLineEdit("LineEditA1"); QLineEdit *LineEditA2 = new QLineEdit("LineEditA2"); QGridLayout *lay = new QGridLayout(grupa); lay-&gt;addWidget(labelA1, 0, 0, Qt::AlignLeft); lay-&gt;addWidget(LineEditA1, 0, 1, Qt::AlignLeft); lay-&gt;addWidget(labelA2, 1, 0, Qt::AlignLeft); lay-&gt;addWidget(LineEditA2, 1, 1, Qt::AlignLeft); grupa-&gt;setLayout(lay); } classA::~classA(){} classB::classB(QWidget *parent) : QWidget(parent) { QGroupBox *grupa = new QGroupBox(tr("classB"),this); QLabel *labelB1 = new QLabel(tr("Label B1")); QLabel *labelB2 = new QLabel(tr("Label B2")); QLineEdit *LineEditB1 = new QLineEdit("LineEditB1"); QLineEdit *LineEditB2 = new QLineEdit("LineEditB2"); QGridLayout *lay = new QGridLayout(grupa); lay-&gt;addWidget(labelB1, 0, 0, Qt::AlignLeft); lay-&gt;addWidget(LineEditB1, 0, 1, Qt::AlignLeft); lay-&gt;addWidget(labelB2, 1, 0, Qt::AlignLeft); lay-&gt;addWidget(LineEditB2, 1, 1, Qt::AlignLeft); grupa-&gt;setLayout(lay); } classB::~classB(){} </code></pre> <p>As a result, I should see a window with a nicely spaced elements. Unfortunately, I have something like this:</p> <p><img src="https://i.stack.imgur.com/uqf3K.jpg" alt="alt text"></p> <p>What am I doing wrong that these items will not spaced properly?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload