Results 1 to 8 of 8

Thread: Visibility of QDialog

  1. #1
    Join Date
    Jul 2009
    Posts
    40
    Thanks
    7

    Default Visibility of QDialog

    Hello

    I am doing the following :

    1) I am showing dialog in my app. The dialog by default get centered over the main wndow.

    2) the user moves the dialogs to some other position.

    3) After the user moves the dialog to the new position I am hiding
    the dialog with hide function i.e setVisible(false)

    4) After hiding the dialog, after some other code, I am showing the dialog again with show i.e setVisible ( true)

    Problem :
    After showing the dialog it doesnot shows itself at the new positionthat was moved to i.e it shows centered on my main window.
    Is this normal behavior , or should I manually preserve the position some how?

    Thanks

  2. #2
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Visibility of QDialog

    Because of the dialog is child of main window, it has to show within parent(mainwindow) boundary.
    If you want to move it to some other position. Dont create dialog as child of mainwindow or use global position like this
    Qt Code:
    1. yourWidget->mapToGlobal( QPoint);
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2009
    Posts
    40
    Thanks
    7

    Default Re: Visibility of QDialog

    "Because of the dialog is child of main window, it has to show within parent(mainwindow) boundary."

    Yes, but I am not moving the dialog out of the parent boundary.
    So it should not be a problem, right ?

  4. #4
    Join Date
    Dec 2007
    Posts
    628
    Thanks
    3
    Thanked 89 Times in 87 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Visibility of QDialog

    Whats the problem in storing global position before hiding and using same position after showing.

  5. #5
    Join Date
    Jul 2009
    Posts
    40
    Thanks
    7

    Default Re: Visibility of QDialog

    I think that is not elegant solution
    so I want to consider some other options

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Visibility of QDialog

    dont waste your time... on other "elegant" options..
    you have to save your dialog's position upon hiding. this is the only way. take a look at QSettings.

  7. The following user says thank you to nish for this useful post:

    elizabeth.h1 (15th October 2009)

  8. #7
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: Visibility of QDialog

    How do you hide the dialog? Do you maybe create a new instance of the dialog everytime you show it?
    It's nice to be important but it's more important to be nice.

  9. #8
    Join Date
    Jul 2009
    Posts
    40
    Thanks
    7

    Default Re: Visibility of QDialog

    no I do not create a new instance, am using hide nad show on the same dialog instance

Similar Threads

  1. closing a Qdialog called from a Qdialog
    By OverTheOCean in forum Qt Programming
    Replies: 3
    Last Post: 28th September 2009, 08:02
  2. adding QAction to QDialog is not working
    By sanjayshelke in forum Qt Programming
    Replies: 3
    Last Post: 13th August 2008, 09:39
  3. QDialog / QListView problem
    By harakiri in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2007, 18:31
  4. Resizing a QDialog to the content size
    By Nyphel in forum Qt Programming
    Replies: 8
    Last Post: 15th March 2007, 08:16
  5. Qdialog as a child widget
    By dave in forum Newbie
    Replies: 12
    Last Post: 14th November 2006, 09:43

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.