Call MainWindow through QDialog
Hi.
Some say I know how do I show a MainWindow starting from a QDialog?
Regards,
Daniel Sousa
Re: Call MainWindow through QDialog
If you know then please share :)
If you don't know, please elaborate what you mean.
Re: Call MainWindow through QDialog
Quote:
Originally Posted by
Spitfire
If you know then please share :)
If you don't know, please elaborate what you mean.
Sorry but I can not write very well English.
I want to know how a call MainWindow when I click a button on a QDialog.
regards,
Daniel Sousa
Re: Call MainWindow through QDialog
Do you have both dialog and main window and you just want to show main window over the dialog?
Is the main window hidden?
Do you want to create main window on button press?
Is the dialog modal?
Od maybe you want to call a method in main window class when some button in the dialog is pressed?
English may not be your mother tongue, but google is your friend.
Write best description you can in your language and then translate it to english using google.
From what you said I can't figure out what you need.
Sorry :/
Re: Call MainWindow through QDialog
Quote:
Originally Posted by
Spitfire
Do you have both dialog and main window and you just want to show main window over the dialog?
Is the main window hidden?
Do you want to create main window on button press?
Is the dialog modal?
Od maybe you want to call a method in main window class when some button in the dialog is pressed?
English may not be your mother tongue, but google is your friend.
Write best description you can in your language and then translate it to english using google.
From what you said I can't figure out what you need.
Sorry :/
I want to start the application and opens a QDialog, after I click a button create a MainWindow.
Re: Call MainWindow through QDialog
If you can write main window, you should be able to write code below:
Code:
int main(int argc, char *argv[])
{
MagicDialog d( this );
if( d.exec() )
{
MainWindow w;
w.show();
return a.exec();
}
return -1;
}
In MagicDialog connect whatever button you want to accept() slot to show main window, connect other button to reject() to terminate the application.
Re: Call MainWindow through QDialog
Quote:
Originally Posted by
Spitfire
If you can write main window, you should be able to write code below:
Code:
int main(int argc, char *argv[])
{
MagicDialog d( this );
if( d.exec() )
{
MainWindow w;
w.show();
return a.exec();
}
return -1;
}
In MagicDialog connect whatever button you want to accept() slot to show main window, connect other button to reject() to terminate the application.
I tried the code and you said to me the following error:
/ Users/danielsousa/Qt/Interface2-build/../Interface2/main.cpp: 8: error: invalid use of 'this' in non-member function
Re: Call MainWindow through QDialog
D-oh, no need for parent there, just remove it.
Should be obvious.
Re: Call MainWindow through QDialog
Quote:
Originally Posted by
Spitfire
D-oh, no need for parent there, just remove it.
Should be obvious.
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Inicio d();
if(d.exec()){
MainWindow w;
w.show();
return a.exec();
}
//Inicio w;
//w.show();
return -1;
}
I like the code on top and me the error: /Users/danielsousa/Qt/Interface2-build/../Interface2/main.cpp:10: error: request for member 'exec' in 'd', which is of non-class type 'Inicio ()()'
Re: Call MainWindow through QDialog
So, why you're talking about dialog when you're not using a dialog?
Is your 'dialog' a QWidget?
Use QDialog as a base class.
And read the docummentation for QDialog.
Re: Call MainWindow through QDialog
Quote:
Originally Posted by
Spitfire
So, why you're talking about dialog when you're not using a dialog?
Is your 'dialog' a QWidget?
Use QDialog as a base class.
And read the docummentation for QDialog.
But I'm using a QDialog. I want to click a button that a QDialog and open a MainWindow
Re: Call MainWindow through QDialog
My bad, need to read the error to the end next time :)
Drop the () from Inicio.
Code:
Inicio d;
if(d.exec())
...
and use [CODE] tags.
Re: Call MainWindow through QDialog
Quote:
Originally Posted by
Spitfire
My bad, need to read the error to the end next time :)
Drop the () from Inicio.
Code:
Inicio d;
if(d.exec())
...
and use [CODE] tags.
This works, but now I when I click a button from QDialog closes the application.
And instead of closing the application you want to open the MainWindow.
How do I make it?
Re: Call MainWindow through QDialog
Quote:
In MagicDialog connect whatever button you want to accept() slot to show main window, connect other button to reject() to terminate the application.
PS. I did not know that quote doesn't count towrads message length :>
Edit: ok, in case you don't know:
Code:
// dialog constructor or wherever you create the buttons
connect( button_closing_dialog, SIGNAL( clicked() ), this, SLOT( reject() ) );
connect( button_showin_app, SIGNAL( clicked() ), this, SLOT( accpet() ) ) ;