Results 1 to 5 of 5

Thread: QDialog issues

  1. #1
    Join Date
    Mar 2006
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QDialog issues

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog issues

    Who is the parent of that dialog? How do you invoke the base class constructor in your dialog's constructor?

  3. #3
    Join Date
    Mar 2006
    Posts
    29
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog issues

    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);
    }

  4. #4
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog issues

    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.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDialog issues

    Quote Originally Posted by munna
    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.

Similar Threads

  1. adding QAction to QDialog is not working
    By sanjayshelke in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2008, 09:39
  2. QDialog margin and spacing
    By TheRonin in forum Qt Programming
    Replies: 4
    Last Post: 29th October 2007, 10:11
  3. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  4. Qdialog as a child widget
    By dave in forum Newbie
    Replies: 12
    Last Post: 14th November 2006, 09:43
  5. QDialog Issues
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 17th October 2006, 08:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.