B
B
Blunker2015-11-27 13:24:58
Qt
Blunker, 2015-11-27 13:24:58

How to place components on the same form?

The bottom line is: there is a class

class GameButton : public QPushButton
{
public:
     GameButton(QWidget *parent = 0) : QPushButton(parent) {}
protected:
    bool player;
};

main class
class GameButton;

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
private:
    Ui::MainWindow *ui;
    GameButton *but;
    QHBoxLayout *one, *two, *three, *mainLayout;

};

constructor
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    one = new QHBoxLayout;

    but = new GameButton[9];

    setFixedSize(875, 444);

    one->addWidget(btn);
    one->addWidget(&but[0]);
    one->addWidget(&but[1]);
    setLayout(one);
}

I put 2 groupboxes in the designer and I need to put GameButton objects on these groupboxes. You can’t do this from the designer, you need to programmatically. When placed on a Layout, all buttons open in separate windows.
Help:)

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
Jacob E, 2015-11-27
@Zifix

Where do you work with GroupBoxes? You didn't even use them anywhere.

When placed on a Layout, all buttons open in separate windows.
Have you tried to act not only by the poke method, but also read a book on Qt?

A
Anatoly Medvedev, 2015-11-27
@balamyt92

I agree with the previous speaker.
I gave you the link in my last post . Read until enlightened. Elementary things. I don't know, look at the video on YouTube or something ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question