Results 1 to 7 of 7

Thread: Multiple tabbed QDockWidget and default selection

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2011
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Multiple tabbed QDockWidget and default selection

    thanks srazi.. your solution is great....

  2. #2

    Default Re: Multiple tabbed QDockWidget and default selection

    It does not work for me.
    firstTab->raise() has no effect. Any ideas?

  3. #3
    Join Date
    Mar 2012
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Multiple tabbed QDockWidget and default selection

    I'm also having an issue with this. I would appreciate any advice on being able to set the current tabbed dockwidget.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Multiple tabbed QDockWidget and default selection

    Call QWidget::raise() on the dock widget you want on top. There's not much more to it than that.
    Qt Code:
    1. #include <QtGui>
    2. #include <QDebug>
    3.  
    4. class MainWindow: public QMainWindow {
    5. Q_OBJECT
    6. public:
    7. MainWindow(QWidget *p = 0): QMainWindow(p) {
    8. setCentralWidget(new QTextEdit(this));
    9.  
    10. dock1 = new QDockWidget("Dock1", this);
    11. dock1->setWidget(new QLabel("Dock 1 content", this));
    12. addDockWidget(Qt::RightDockWidgetArea, dock1);
    13. dock2 = new QDockWidget("Dock2", this);
    14. dock2->setWidget(new QLabel("Dock 2 content", this));
    15. addDockWidget(Qt::RightDockWidgetArea, dock2);
    16. tabifyDockWidget(dock1, dock2);
    17.  
    18. flop = true;
    19. connect(&timer, SIGNAL(timeout()), SLOT(flip()));
    20. timer.start(2000);
    21. }
    22. public slots:
    23. void flip() {
    24. if (flop)
    25. dock1->raise();
    26. else
    27. dock2->raise();
    28. flop = !flop;
    29. }
    30.  
    31. private:
    32. QDockWidget *dock1;
    33. QDockWidget *dock2;
    34. QTimer timer;
    35. bool flop;
    36. };
    37.  
    38. int main(int argc, char *argv[])
    39. {
    40. QApplication app(argc, argv);
    41.  
    42. MainWindow m;
    43. m.show();
    44. return app.exec();
    45. }
    46. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 
    "We can't solve problems by using the same kind of thinking we used when we created them." -- Einstein
    If you are posting code then please use [code] [/code] tags around it - makes addressing the problem easier.

Similar Threads

  1. Default size of a QListWidget inside a QDockWidget
    By rakuco in forum Qt Programming
    Replies: 0
    Last Post: 25th July 2007, 08:01
  2. different arrangement of QDockWidget than default
    By Wurgl in forum Qt Programming
    Replies: 3
    Last Post: 13th July 2006, 10:41

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
  •  
Qt is a trademark of The Qt Company.