Results 1 to 2 of 2

Thread: QDockWidget floating as a window

  1. #1
    Join Date
    Jun 2012
    Posts
    19
    Thanks
    3

    Default QDockWidget floating as a window

    i've got a little class which allows dockwidgets to be minimzed or closed once they're floating. on windows, this works without issue, however on linux (ubuntu) when the qdockwidgets are 'undocked' and floating, they don't draw, they're black rectangles. the really weird part, is if i step through with the debugger in the 'floating_changed' below, they show up properly?

    is there a better way to accomplish this?

    Qt Code:
    1. class BaseDock : public QDockWidget {
    2. Q_OBJECT
    3. public:
    4. BaseDock(QWidget *parent = 0, Qt::WindowFlags flags = 0)
    5. :QDockWidget(parent,flags)
    6. {
    7. connect(this,SIGNAL(topLevelChanged(bool)),this,SLOT(floating_changed(bool)));
    8. }
    9.  
    10. private slots:
    11. void floating_changed(bool floating){
    12. if(this->isVisible() && floating){
    13. this->setWindowFlags(Qt::Window);
    14. QPoint pos = this->pos();
    15. if(pos.x() < 0)
    16. pos.setX(0);
    17. if(pos.y() < 0)
    18. pos.setY(0);
    19. this->move(pos);
    20. this->show();
    21. }
    22. }
    23.  
    24. };
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jun 2012
    Posts
    19
    Thanks
    3

    Default Re: QDockWidget floating as a window

    alright after more tinkering i've revised the slot's code, which seems to work better:
    Qt Code:
    1. void floating_changed(bool floating){
    2. bool vis = this->isVisible();
    3. if(floating){
    4. this->setWindowFlags(Qt::Window);
    5. QPoint pos = this->pos();
    6. if(pos.x() < 0)
    7. pos.setX(0);
    8. if(pos.y() < 0)
    9. pos.setY(0);
    10. this->move(pos);
    11.  
    12. if(vis)
    13. this->show();
    14. }
    15. }
    To copy to clipboard, switch view to plain text mode 

    now the issue persists on linux only under a particular circumstance. first let me show the code that initializes the docks, in case there's something wrong there. all docks are setup like this:
    Qt Code:
    1. PreferencesDock *pref_dock = new PreferencesDock(this); //this dock inherits the baseDock outlined in the first post.
    2. pref_dock->setHidden(true);
    3. pref_dock->setFloating(false);
    4. addDockWidget(Qt::RightDockWidgetArea, pref_dock);
    5.  
    6. ui->menu_docks->addAction(pref_dock->toggleViewAction());
    To copy to clipboard, switch view to plain text mode 
    so, when running in windows all is fine. under linux (ubuntu) if a dock is added to a dock area on the sides of the application, and then you click the little 'undock' button to pop it out, that's when the issue occurs. it pops out the dock (floating mode) but, it doesn't draw it. it's just a rectangle on the screen where it should be.

    the above 'floating_changed' is being called when it's popped out to floating mode, and if i put a break point in that code, then the dock is properly drawn as expected!?

Similar Threads

  1. Events of floating QDockWidget
    By harregui in forum Qt Programming
    Replies: 8
    Last Post: 20th January 2017, 16:21
  2. Maximizing a floating QDockWidget?
    By blackmarlin in forum Qt Programming
    Replies: 1
    Last Post: 22nd December 2012, 10:25
  3. QDockWidget floating at the beginning
    By Caius Aérobus in forum Qt Programming
    Replies: 0
    Last Post: 2nd March 2011, 13:15
  4. Replies: 1
    Last Post: 7th December 2010, 21:46
  5. QDockWidget : No floating
    By prashant in forum Qt Programming
    Replies: 1
    Last Post: 5th October 2009, 18:42

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.