Results 1 to 3 of 3

Thread: Can't close my popup

  1. #1
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Can't close my popup

    I have created a widget that has a QToolButton that, when clicked, calls the following slot:
    Qt Code:
    1. void ParentWidget::ButtonClickedSlot()
    2. {
    3. // If already shown then hide the popup
    4. if( !mMyPopup->isHidden() )
    5. {
    6. mMyPopup->hide();
    7. }
    8. else
    9. {
    10. // Build the Rect and show the window
    11. QRect newRect( x, y, mDropWidth, mDropHeight );
    12. mMyPopup->setGeometry( newRect );
    13. mMyPopup->show();
    14.  
    15. }
    16. }
    To copy to clipboard, switch view to plain text mode 

    In the constructor of the popup I have set a couple of flags:
    Qt Code:
    1. setWindowFlags( Qt::Popup | Qt::MSWindowsFixedSizeDialogHint );
    To copy to clipboard, switch view to plain text mode 

    When I first click the button, the popup pops up as expected. If I click anywhere in the application, the popup hides (I think this is the result of having set the Qt::Popup flag because I didn't write any code to cause the popup to hides that way). The problem I am having is that if I click on the QToolButton when the popup is open already, the click causes the popup to hide, and then the ButtonClickedSlot is called which causes the popup to show again.

    I've worked at this one for a while but I don't seem to be making any progress. Any suggestions would be greatly appreciated.

    James

  2. #2
    Join Date
    Jan 2006
    Location
    Edmonton, Canada
    Posts
    101
    Thanks
    13
    Thanked 6 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Can't close my popup

    Perhaps a better way to phrase my quesiton is this:

    I'd like to be able to toggle a popup open/closed using a button. I can get it to open, but I can't get it to close.

    Any ideas on how I can fix this, or an alternative approach, would be greatly appreciated.

  3. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Can't close my popup

    I think you can cut Qt::Popup flag and do show/hide yourself
    a life without programming is like an empty bottle

Similar Threads

  1. Background image on popup menu item
    By MarkoSan in forum Qt for Embedded and Mobile
    Replies: 1
    Last Post: 27th June 2006, 05:55
  2. Replies: 1
    Last Post: 1st June 2006, 12:46
  3. Replies: 6
    Last Post: 14th April 2006, 05:39
  4. connect on a popup
    By mickey in forum Qt Programming
    Replies: 2
    Last Post: 12th April 2006, 16:37

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.