Results 1 to 3 of 3

Thread: Available action in main window menu even when dockwidget still doesn't exists

  1. #1
    Join Date
    Feb 2010
    Location
    Brazil
    Posts
    23
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Available action in main window menu even when dockwidget still doesn't exists

    I was taking a look at the Dock Widgets example that comes with Qt. It can be found here.

    In MainWindow::createDockWindows() a QDockWidget instance is created and its address is passed to a pointer called 'dock'. The main window has a menu item called 'view' that shows a toggle action to show or hide the available dockwidgets. It adds the toggle item to the menu with this: viewMenu->addAction(dock->toggleViewAction());

    Suppose that in another application, a few particular dockwidgets are created at runtime. If i did the same way as the example, the toggle items for each particular dockwidget would only show in the viewMenu after they are created, but I'd like to have them exist even when the dockwidget itself haven't been created yet. The item in the viewMenu would be inert, but would work after the dockwidget is created. How can I do that?
    Last edited by tiredtyrant; 20th April 2010 at 21:50.

  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: Available action in main window menu even when dockwidget still doesn't exists

    Well, then you have to create your own toggle-able action and connect it to the dock widget when it is created. Signal toggled(bool) and slot setVisible().

  3. The following user says thank you to Lykurg for this useful post:

    tiredtyrant (20th April 2010)

  4. #3
    Join Date
    Feb 2010
    Location
    Brazil
    Posts
    23
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Available action in main window menu even when dockwidget still doesn't exists

    It worked, thanks!

Similar Threads

  1. Menu open action -reg
    By jsmith in forum Qt Programming
    Replies: 1
    Last Post: 8th May 2009, 12:07
  2. Check if window with certain title exists
    By devil in forum Qt Programming
    Replies: 5
    Last Post: 21st January 2009, 15:42
  3. Replies: 11
    Last Post: 11th August 2008, 10:14
  4. copy/paste actions in main window menu
    By magland in forum Qt Programming
    Replies: 3
    Last Post: 2nd October 2007, 13:33
  5. Replies: 15
    Last Post: 23rd March 2007, 17:16

Tags for this Thread

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.