PDA

View Full Version : QDialog issues



vijay anandh
19th May 2006, 16:45
Hi All

I am vijay anandh using VS2005 with Qt 4.1 integration.

I created a class which is derived from QDialog and i created instance for that class in another one class. Everything works fine.

But what's problem , that dialog is launched in different positions on screen, I want to be displayed at center positon of the screen. what i have to do for this

looking forward your reply

thanks and regards
vijay

jacek
19th May 2006, 16:49
Who is the parent of that dialog? How do you invoke the base class constructor in your dialog's constructor?

vijay anandh
20th May 2006, 08:40
Hi
Thanks for your mail.

Dialog class name is MyDialog , the constructor is

MyDialog::MyDialog(QWidget *parent)
: QDialog(parent)
{

}


In Class Sample1.h file i included MyDialog.h header file and in Cpp file i placed one QPushButton . when we click that push Button , I want to display MyDialog class.


Here is the code which i wrote

void Sample1::showMydialog()
{
MyDialog *dlg=new MyDialog(this);
}

munna
20th May 2006, 08:59
your MyDialog will be placed in the center of Sample1 Widget and not the screen.

Using QDesktopWidget you can get the size of the screen and then center your MyDialog.

jacek
20th May 2006, 13:41
Using QDesktopWidget you can get the size of the screen and then center your MyDialog.
AFAIR it will be enough, if you won't specify the parent.