Re: Dialogs in MainWindow
QWizard seems to be what you need.
Re: Dialogs in MainWindow
Even if you use QWizard, you still have to create a class or other data structure that will hold the information the user is entering as they go from page to page.
If you want the action of going back to the previous page to restore the default values (not the values as changed by the user), then you either need to keep two copies of the data structure (one with defaults, one with edited values), and swap them as required, or respond to the back action by resetting the values to the defaults..
I think the idea of clicking a Back button and seeing that all the values I just spent 10 minutes editing are gone would really annoy me. A better design would be to have a button on each page that says "Reset" or something like that, and only replace the user's values with the defaults when they ask you to (by clicking Reset).
Re: Dialogs in MainWindow
Hmm I dont know that you understand what I want to do. So I will tell everything:
It's poker network game. First when we launch app we have Login/Register window which disappear when we log in.
Then we see second window with tables which you can join, chat and something like list of online users. When we join to one of the tables then we see window with game, but i dont want to open everytime new window and close that previous(second one) but show game in this main window with tables.
How to do something like this? As I said i tried with qstackedwidgets but it's not good idea, so I think that qwizard is something similar and does not meet requirements. I tried to do it that we have 3 windows(but it looks bad), one with login, second with tables and third with gameplay but there I have a problem that when i close second window and open third(when click join button) and then want to leave game and come back to tables view I can't invoke second window from third even if I include headers to second window. If there is no possibility to do it in one window, so how to do it with this three?
Re: Dialogs in MainWindow
You *can* do this easily with a stack widget. The whole purpose of a stack widget is to allow you to display multiple windows, one at a time, in the same space.
If you want to be able to switch back and forth between the gameplay view and tables view, simply put a button on each of those pages that the user can click. On the tables view, it says "Show game" and on the gameplay view it says "Show tables" or something like that. In the main window, add slots that connect the clicked() signals from these buttons to switch the stack to the proper page, something like this:
Code:
// GamePlayView.h
#include "MainWindow.h"
{
public:
{
// ... ui setup
connect( ui->switchViewButton, SIGNAL( clicked() ), pMain, SLOT( showTablesView() ) );
}
// ...
};
Code:
// TablesView.h
#include "MainWindow.h"
{
public:
{
// ... ui setup
connect( ui->switchViewButton, SIGNAL( clicked() ), pMain, SLOT( showGamePlayView() ) );
}
// ...
};
Code:
// MainWindow.h
#include <QMainWindow>
{
public:
MainWindow
( QWidget * parent
= 0 );
public slots:
void showTablesView();
void showGamePlayView();
private:
};
Code:
// MainWindow.cpp
#include <QStackedWidget>
#include "LoginView.h"
#include "TablesView.h"
#include "GamePlayView.h"
MainWindow
::MainWindow( QWidget * parent
= 0 );
{
// ... ui setup
pStack->addWidget( new LoginView( this ) );
pStack->addWidget( new TablesView( this ) );
pStack->addWidget( new GamePlayView( this ) );
setCentralWidget( pStack );
pStack->setCurrentIndex( 0 );
}
void MainWindow::showTablesView()
{
pStack->setCurrentIndex( 1 );
}
void MainWindow::showGamePlayView()
{
pStack->setCurrentIndex( 2 );
}