Hey,
I am currently creating a program and have encountered a small problem.
I have a QWidget (MainMenu) with a pushbutton on and a slot called void MainMenu::button1Clicked();
On the click of this button, it closes MainMenu and opens up my second widget (PageTwo).
This works fine, however on PageTwo, the pushbutton to return to MainMenu does not work, it simply closes the widget as it is supposed to, but doesnt run MainMenu
Mainmenu class: (button works fine!)
MainMenu
::MainMenu(QWidget *parent
)
{
connect(button1, SIGNAL(clicked()),MainMenu1, SLOT(close()));
connect(button1,SIGNAL(clicked()),this,SLOT(button1Clicked()));
MainMenu -> show();
}
void MainMenu::button1Clicked()
{
Page2 w;
}
MainMenu::MainMenu(QWidget *parent)
: QWidget(parent)
{
QWidget *MainMenu1 = new QWidget;
QPushButton *button1 = new QPushButton;
connect(button1, SIGNAL(clicked()),MainMenu1, SLOT(close()));
connect(button1,SIGNAL(clicked()),this,SLOT(button1Clicked()));
MainMenu -> show();
}
void MainMenu::button1Clicked()
{
Page2 w;
}
To copy to clipboard, switch view to plain text mode
My second class , it opens up fine but will not run MainMenu when the button is clicked as it does the first time
{
connect(button2, SIGNAL(clicked()),PageTwo, SLOT(close()));
connect(button2,SIGNAL(clicked()),this,SLOT(button2Clicked()));
PageTwo -> show();
}
void Page2::button2Clicked()
{
MainMenu w;
}
Page2::Page2(QWidget *parent)
: QWidget(parent)
{
QWidget *PageTwo = new QWidget;
QPushButton *button2 = new QPushButton;
connect(button2, SIGNAL(clicked()),PageTwo, SLOT(close()));
connect(button2,SIGNAL(clicked()),this,SLOT(button2Clicked()));
PageTwo -> show();
}
void Page2::button2Clicked()
{
MainMenu w;
}
To copy to clipboard, switch view to plain text mode
Thanks in advance for any replies.. It is really confusing me as to why the first button works perfectly fine but the second one will not even though the code is practically the same...
P.S i am not recieving any errors, main menu is just not showing!
Bookmarks