PDA

View Full Version : How to create QDialog with QT Creator and connect it to the source?



unix7777
23rd December 2010, 22:27
There are several examples of QDialog and how to create it.
The missing one is how can i create QDialog using QT Creator ( .ui file) and then connect it to the source.I'm trying to create simple About dialog.
I know QMessage is the simple way.I just want to understand creating application with multiple dialogs how can i connect the .ui file with the source in order to make them all work.

Thanks is advance

marcvanriet
23rd December 2010, 22:54
:confused:

In the 'File menu' :
New file or project
Files and classes : Qt
Qt Designer Form class

It doesn't get any simpler than that...

For creating an application with multiple dialogs : there have been maybe 20 threads on how to do this in this forum, and it is even mentioned in the FAQ.

Regards,
Marc

unix7777
25th December 2010, 15:39
obviously i was misunderstood!

I know how to create an .ui file.
The problem is how to make it work.
For example, lets have one button and when user click on it to open about dialog.
OK, but the dialog to be created with QTDesigner.
The problem is how to make this connection
i'm attaching the project file.

Zlatomir
25th December 2010, 15:57
You are using uninitialized pointer in there, your slot should look like this:


void Imoti::on_pushButton_clicked()
{
about *one = new about(this); //use a pointer and then create the object and allocate memory with new
one->show(); //non-modal
}
or, in case you want modal:


void Imoti::on_pushButton_clicked()
{
about one(this); //create a object directly
one.exec(); //modal dialog
}

LE: added 'this' as a parent for modal dialog too...

unix7777
25th December 2010, 16:20
thanks a lot!!!