B
B
Blunker2015-11-27 14:49:02
Qt
Blunker, 2015-11-27 14:49:02

How to add elements to a form?

There is a form created in qt designer how to add elements to it programmatically?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anatoly Medvedev, 2015-11-27
@balamyt92

QWidget *window = new QWidget;
    QPushButton *button1 = new QPushButton("One");
    QPushButton *button2 = new QPushButton("Two");
    QPushButton *button3 = new QPushButton("Three");
    QPushButton *button4 = new QPushButton("Four");
    QPushButton *button5 = new QPushButton("Five");

    QHBoxLayout *layout = new QHBoxLayout;
    layout->addWidget(button1);
    layout->addWidget(button2);
    layout->addWidget(button3);
    layout->addWidget(button4);
    layout->addWidget(button5);

    window->setLayout(layout);
    window->show();

Result:
more here

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question