I’m writing my own messenger and I need to make 2 forms with an input and a main window. For this I decided to use qstackedlayout which will be linked to qwidget. All descendants of the form class (entrance or main window - no difference) are displayed normally, but the widget itself is not.
This is the window constructor code (which is from qwidget):
MainWindow::MainWindow(QWidget* parent) : QWidget(parent) { m_net = new NetworkController(this); m_mainScene = new MainScene(this, m_net); m_loginScene = new LoginScene(this, m_net); m_stackLayout = new QStackedLayout(this); connect(m_net, SIGNAL(succesfullLogin(QUuid)), this, SLOT(on_succesfullLogin(QUuid))); connect(m_net, SIGNAL(succesfullLogin(QUuid)), m_mainScene, SLOT(on_succesfullLogin(QUuid))); connect(m_net, SIGNAL(succesfullLogin(QUuid)), m_loginScene, SLOT(on_succesfullLogin(QUuid))); connect(m_net, SIGNAL(lostConnection()), this, SLOT(on_lostConnection())); m_stackLayout->addWidget(m_loginScene); m_stackLayout->addWidget(m_mainScene); m_stackLayout->setCurrentIndex(0); }When you run it you get the following:
ed7c4fbf-1f7d-4ad7-a4d7-2542e11b714f-image.png
But in qt designer it looks like this:
7f08e07b-c84f-4bd6-8058-e6e5caf40bd9-image.png
MainScene and LoginScene are just classes inherited from qwidget, in their constructor I just call setupUi(this) and that’s it
I can’t figure out what I’m doing wrong for a long time, I hope you can help