I managed to get a QPushButton to open a new window when pressed by using the following code (just snippets of code):
AppDialog::AppDialog(QWidget *parent)
: QDialog(parent)
{
QPushButton *button3 = new QPushButton(tr("Apps"));
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->addWidget(button3);
setLayout(hLayout);
}
MainWindow::MainWindow()
{
mainMenu = new MainMenu;
setCentralWidget(mainMenu);
app = 0;
readSettings();
}
void MainWindow::AppMenu()
{
app = new AppDialog(this);
app->show();
}
This opens in a new window with an "App" button in it. Can anyone let me know if it's possible and how to open the new app dialog in the same window as the original main menu? It should cover the whole window and look like a normal window with the new menu on it. Ideally after this I could add a "back" button of some sort. I guess this is similar to creating a "wizard" type of interface that is used a lot on the installation wizards and stuff like that.
Bryce
EDIT
This is the source code for implementing QStackedWidgets()
MainMenu::MainMenu(QWidget *parent)
: QDialog(parent)
{
QStackedLayout *stackedLayout = new QStackedLayout;
AppDialog *app = new AppDialog;
progWidget *program = new ProgWidget;
QStackedWidget *stackedWidget = new QStackedWidget;
stackedWidget->addWidget(app);
stackedWidget->addWidget(program);
stackedWidget->setCurrentIndex(0);
QVBoxLayout *vLayout = new QVBoxLayout;
vLayout->addWidget(stackedWidget);
setLayout(vLayout);
}
Where would I put the signals and slots to change the index? Imaging that the app and program widgets are just a few widgets with some QPushButtons on them. I can get them to display separately but haven't figure out how to change them yet.