Results 1 to 4 of 4

Thread: Synchronizing "Show XXX window" action checked state with some window's visibility

  1. #1
    Join Date
    Oct 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Synchronizing "Show XXX window" action checked state with some window's visibility

    Hello,

    In my soft, I've got a windows and a menu item and related action to control the window's visibility. The action is checkable, so I can do

    Qt Code:
    1. connect(action, SIGNAL(toggled(bool)), window, SLOT(setVisible(bool)));
    To copy to clipboard, switch view to plain text mode 

    Is there an easy way to do the opposite -- ie. have the toggled state of the action updated whenever the visibility of the window changes?

    TIA,
    Antoine

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Synchronizing "Show XXX window" action checked state with some window's visibilit

    Yes: QWidget::setHidden().

    Edit: Ehm, forget about it, misread


    Edit2: And now the answer: There is no signal but an event: QWidget::showEvent()/QEvent::Show/QEvent::Hide
    Last edited by Lykurg; 17th March 2010 at 16:35.

  3. #3
    Join Date
    Oct 2009
    Posts
    13
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Synchronizing "Show XXX window" action checked state with some window's visibilit

    So the window's parent (say my QMainWindow's subclass) could intercept this event and change the action accordingly, provided that the main windows is somehow the parent of the windows whose visibility we want to track. Is that correct?

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Synchronizing "Show XXX window" action checked state with some window's visibilit

    Your main window mustn't be the parent. I can think of two options: a) install an event filter on your widgets you want to watch or create an abstract class which must be inherited by your windows. There catch the show and hide event and emit custom signals. Then you can use signal and slots as you are used to.

Similar Threads

  1. how to check button state such as "hover"?
    By billconan in forum Qt Programming
    Replies: 2
    Last Post: 12th November 2009, 01:45
  2. Replies: 1
    Last Post: 23rd August 2008, 22:09
  3. Qt4 eclipse integration : "action handling"
    By QiT in forum Qt-based Software
    Replies: 1
    Last Post: 24th July 2008, 10:20
  4. Background Style Disables QScrollBar "Drag" Action
    By brent99 in forum Qt Programming
    Replies: 1
    Last Post: 3rd June 2008, 20:16
  5. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.