Results 1 to 6 of 6

Thread: Dock Widget problems

  1. #1
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Dock Widget problems

    Hi

    I have a main window with a dock widget. The dock widget is initially hidden. It is displayed when the user selects the action from a menu (same as dock widgets example), this works fine.

    I also have an icon on a toolbar to control the visibility of the same dock window. I want to be able set enable/disable the icon depending on the visibility of the dock window. How can I achieve this (ideally I would like the menu item and icon controlling the visibility of the dock window to be synchronized)

    Thanks

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

    Default Re: Dock Widget problems

    You can use the same QAction for both the menu and the toolbar.

  3. #3
    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: Dock Widget problems

    Ok, you have a Q<Menu>Action, Q<Toolbar>Action and the QDockWidget. Only connect the Q<Menu>Action to the QDockWidget. (toogle -> setVisible). and then connect the Q<Menu>Action with the Q<Toolbar>Action (toggled -> setChecked) and vice versa.

    Or use QDockWidget::toggleViewAction() direct as an action in your menu.

    Lykurg

  4. #4
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Dock Widget problems

    Hi

    Thanks

    I am using toggleViewAction to populate the menu. How do I use it to control the icon state in my toolbar?

  5. #5
    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: Dock Widget problems

    Qt Code:
    1. QAction toolbaraction = new QAction(...);
    2. QAction act = QDockWidget::toggleViewAction();
    3. QMenu::addAction(act);
    4. connect(act, SIGNAL(toggled(bool)), toolbaraction, SLOT(setChecked(bool)));
    5. connect(toolbaraction, SIGNAL(toggled(bool)), act, SLOT(setChecked(bool)));
    To copy to clipboard, switch view to plain text mode 
    if you want to have different icons etc in menu and toolbar. If not just use the same action as munna has mentioned

  6. #6
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Thumbs up Re: Dock Widget problems

    Thanks Lykurg & munna for your help

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. sliding dock widget
    By manishkyl in forum Qt Programming
    Replies: 0
    Last Post: 28th July 2008, 14:04
  3. Tricky problem with ARGB widget / UpdateLayeredWindow
    By nooky59 in forum Qt Programming
    Replies: 3
    Last Post: 21st February 2008, 10:35
  4. Problems with laying out custom widget
    By mtrpoland in forum Newbie
    Replies: 6
    Last Post: 19th August 2007, 11:43
  5. Pin/Unpin Dock Widget
    By charlesD in forum Newbie
    Replies: 1
    Last Post: 21st June 2006, 06:57

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.