Results 1 to 3 of 3

Thread: Force QDialog to appear just to left of parent?

  1. #1
    Join Date
    Aug 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Force QDialog to appear just to left of parent?

    Is it possible to force a QDialog to be displayed just to the left of its parent?

    Usually, it seems that a QDialog will be displayed at an arbitrary location if it has no parent assigned, or within its parent if one is assigned. I'd like mine (which is a property-setter for a collection of Qwt graphs) to appear alongside the parent, so that it doesn't obscure the very plots that it is meant to be controlling. I can guarantee that there is always enough space for it between the edge of the screen and the edge of the parent.

    I can think of lots of hard ways to do this (such as the brute force method of finding the parent's location, then finding the dialog's size, and calculating the dialog's position accordingly - though I'm not sure even this will work if I want to fix the dialog's position before it has been displayed for the first time). Is there an 'easy' (or at least, an elegant) way?

    Thanks,
    Stephen.

  2. #2
    Join Date
    May 2009
    Location
    USA
    Posts
    300
    Thanks
    82
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Force QDialog to appear just to left of parent?

    Probably because being a newbie I don't know any better, but....

    Qt Code:
    1. QWidget::move(x,y);
    To copy to clipboard, switch view to plain text mode 

    in your dialog definition will set the position of the dialog to x,y.
    Why not just pick an absolute position to the left of main window and set it?
    Not elegant, but it will work.

  3. #3
    Join Date
    Aug 2009
    Posts
    50
    Thanks
    9
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Force QDialog to appear just to left of parent?

    Thanks; if need be then that's what I'll do, but it will take a couple of lines of code to find calculate (x, y) by first of all finding the parent's location, then finding the dialog size, and then setting the dialog's location. Also, though I haven't tried it yet for this case, I have found in the past that size information returned for a widget before it has been displayed for the first time is not always reliable.

    I'm still wondering if there's a more elegant way...

Similar Threads

  1. compilation error
    By jjbabu in forum Qt Programming
    Replies: 30
    Last Post: 8th April 2009, 10:20
  2. Replies: 4
    Last Post: 4th June 2007, 12:07
  3. nmake problems while building mysql driver
    By MarkoSan in forum Installation and Deployment
    Replies: 27
    Last Post: 25th May 2007, 12:57
  4. Replies: 1
    Last Post: 28th July 2006, 14:10
  5. QT4 beginner Fatal Error
    By Remyfr in forum Installation and Deployment
    Replies: 3
    Last Post: 11th March 2006, 01:48

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.