I read the manual but I still cant figure out how to load the 2nd form.
I have two forms
1. mainwindow.ui
2. groupwindow.ui
Below are the files..
main.cpp
#include "ui_mainwindow.h"
//Main program
int main(int argc, char *argv[])
{
Ui::MainWindow ui;
ui.setupUi(mainwindow);
mainwindow->show();
return app.exec();
}
#include "ui_mainwindow.h"
//Main program
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Ui::MainWindow ui;
QMainWindow *mainwindow = new QMainWindow;
ui.setupUi(mainwindow);
mainwindow->show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
mainwindow.h
class MainWindow
: public QMainWindow,
private Ui
::MainWindow,
private Ui
::GroupWindow{
Q_OBJECT
public:
void InitMenu();
public slots:
void OpenGroupWindow();
};
#endif
class MainWindow : public QMainWindow, private Ui::MainWindow, private Ui::GroupWindow
{
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
void InitMenu();
public slots:
void OpenGroupWindow();
};
#endif
To copy to clipboard, switch view to plain text mode
mainwindow.cpp
#include "ui_mainwindow.h"
#include "mainwindow.h"
#include "ui_groupwindow.h"
{
InitMenu();
}
void MainWindow::InitMenu()
{
//groupAction is a menu action in the ui file.
connect(actionGroup, SIGNAL(clicked()), this, SLOT(OpenGroupWindow()));
// Nothing happens when I click / triggered the above menu item. The application compiles without any errors.
}
void MainWindow::OpenGroupWindow()
{
Ui::GroupWindow gwui;
gwui.setupUi(widget);
setCentralWidget(widget);
widget->show();
}
#include "ui_mainwindow.h"
#include "mainwindow.h"
#include "ui_groupwindow.h"
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
{
InitMenu();
}
void MainWindow::InitMenu()
{
//groupAction is a menu action in the ui file.
connect(actionGroup, SIGNAL(clicked()), this, SLOT(OpenGroupWindow()));
// Nothing happens when I click / triggered the above menu item. The application compiles without any errors.
}
void MainWindow::OpenGroupWindow()
{
QWidget *widget = new QWidget;
Ui::GroupWindow gwui;
gwui.setupUi(widget);
setCentralWidget(widget);
widget->show();
}
To copy to clipboard, switch view to plain text mode
Bookmarks