thisshri
thisshri

Reputation: 642

Is it possible to switch between two UI form in one class in qt?

I have following two classes with their UI forms.

  1. loginWindow
  2. mainWindow

Now when I need to go to the mainWindow I click on the push button in loginWindow and a new window pops up that is the mainWindow.

void LoginWindow::on_pbLogin_clicked()
{
    MainWindow *mainW = new MainWindow;
    mainW->show();
}

What I am trying to have is to get the contents of mainWindow in the loginWindow. I could switch/move to mainWindow from LoginWindow in the same window, without mainWindow creating its own window to show its content and I don't want to use qstackedwidget

Is it possible? if yes, how can I achieve this?

Upvotes: 0

Views: 1358

Answers (1)

Kevin Krammer
Kevin Krammer

Reputation: 5207

If we assume that LoginWindow and MainWindow are both derived from QMainWindow (otherwise it wouldn't just be a content switch), then one option other than using a QStackedWidget would be to have the two form classes derive from QWidget and use either as the centralWidget of a single QMainWindow instance.

Upvotes: 1

Related Questions