Results 1 to 3 of 3

Thread: Setting the active tab with tabified docking windows

  1. #1
    Join Date
    May 2009
    Posts
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Setting the active tab with tabified docking windows

    Hi all,

    Okay I've got an application that has some widgets that are docked and tabified using QMainWindow::tabifyDockWidget. The problem I have is that the tab on the right becomes the active tab and I need the tab on the left to be the active tab when the application starts, and I don't see any way to set the active tab. Also it would be convenient to be able to make different tabs active based upon other user input at runtime.

    Any ideas on what I need to do to handle this would be most appreciated.

    Thanks

  2. #2
    Join Date
    May 2009
    Posts
    14
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Setting the active tab with tabified docking windows

    Okay I figured out a very hacky way of doing this, but if somebody knows of a cleaner way then please let me know.

    Qt Code:
    1. void VisualCurryApp::setActiveDockTab( const QDockWidget* dock )
    2. {
    3. QList<QTabBar*> tabBars = findChildren<QTabBar*>();
    4. foreach( QTabBar* bar, tabBars )
    5. {
    6. int count = bar->count();
    7. for (int i = 0; i < count; i++)
    8. {
    9. QVariant data = bar->tabData(i);
    10. QVariant::DataPtr dataPtr = data.data_ptr();
    11. if (dataPtr.data.ptr == dock)
    12. {
    13. bar->setCurrentIndex(i);
    14. }
    15. }
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    Thanks

  3. #3

    Default Re: Setting the active tab with tabified docking windows

    This is old, but still shows up in related Google searches. For anyone else who stumbles on this, the delayed-raise approach suggested here worked for me: http://www.qtcentre.org/threads/4792...ed-QDockWidget

    Unfortunately, it seems that calling raise() immediately still doesn't work in Qt 5.8 under Windows 10.

Similar Threads

  1. setting main application icon on windows
    By JeanC in forum Qt Programming
    Replies: 7
    Last Post: 12th June 2017, 06:35
  2. Setting wallpaper on windows
    By ihoss in forum Qt Programming
    Replies: 19
    Last Post: 18th September 2009, 03:54
  3. Problem with Painter in Qt4.4.1
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 1st September 2008, 14:47
  4. Setting default icon for all windows / dialogs
    By steg90 in forum Qt Programming
    Replies: 1
    Last Post: 5th July 2007, 11:04
  5. Replies: 6
    Last Post: 18th August 2006, 18:50

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.