Results 1 to 18 of 18

Thread: QDockWidgets without central widget

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QDockWidgets without central widget

    Well ,after looking closer, I reenabled the size constraints and size policies you added and the weird behavior is coming after all from the sizes you give.

    - the windows may now be dropped more or less wherever I try to drop them. There still exists some issue with the resizing bars though, they won't allow me to shrink windows sometimes even though they are well above their minimum size (and the window on the opposite side of the bar is well below its maximum size).
    Doc area no. 2 has a way too smaller maximum size and everything gets screwed by that.

    1) When you start the application you can notice an empty area above the docs. That should not happen.

    2) The docs cannot be moved nor resized normally, because doing so would break dock 2 maximum size. So the main window layout holds them in place.

    So, one thing you should consider is being really careful when setting minimum/maximum sizes.
    Widgets tend to behave well enough with their size hints given by their contents and/or layouts.

    I do intend to save configurations programatically and restore these for the less meddlesome users, but I also want to accomodate those who want to tweak the display to their liking.
    A complete example about this can be found in the demo I mentioned earlier.

    Here's the dock function, in case you want to test it:
    Qt Code:
    1. void MainWindow::createDockWindows()
    2. {
    3. QDockWidget *dock = new QDockWidget(tr("One"), this);
    4. dock->setFeatures( QDockWidget::DockWidgetMovable );
    5. OneDisplaySA = new QScrollArea( dock );
    6.  
    7. OneDisplay = new QLabel("", OneDisplaySA);
    8. OneDisplay->setText("xxx");
    9.  
    10. OneDisplaySA->setBackgroundRole( QPalette::Dark );
    11. OneDisplaySA->setWidget( OneDisplay );
    12. OneDisplaySA->setMinimumSize( 600, 240 );
    13. OneDisplaySA->setMaximumSize( 1500,1000 );
    14. OneDisplaySA->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::MinimumExpanding);
    15. OneDisplaySA->ensureWidgetVisible( OneDisplay );
    16. dock->setWidget( OneDisplaySA );
    17. addDockWidget(Qt::BottomDockWidgetArea, dock);
    18. viewMenu->addAction(dock->toggleViewAction());
    19.  
    20. dock = new QDockWidget(tr("Two"), this);
    21. TwoDisplaySA = new QScrollArea( dock );
    22. TwoDisplay = new QLabel("XXX", TwoDisplaySA);
    23.  
    24. TwoDisplaySA->setBackgroundRole( QPalette::Dark );
    25. TwoDisplaySA->setWidget( TwoDisplay );
    26. TwoDisplaySA->setMinimumSize( 300,120 );
    27. TwoDisplaySA->setMaximumSize( 500,240 );
    28. TwoDisplaySA->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    29. TwoDisplaySA->ensureWidgetVisible( TwoDisplay );
    30. dock->setWidget( TwoDisplaySA );
    31. addDockWidget(Qt::BottomDockWidgetArea, dock);
    32. viewMenu->addAction(dock->toggleViewAction());
    33.  
    34. dock = new QDockWidget(tr("Three"), this);
    35. ThreeDisplaySA = new QScrollArea( dock );
    36. ThreeDisplay = new QLabel("XXX", ThreeDisplaySA);
    37.  
    38. ThreeDisplaySA->setBackgroundRole( QPalette::Dark );
    39. ThreeDisplaySA->setWidget( ThreeDisplay );
    40. ThreeDisplaySA->setMinimumSize( 120,120 );
    41. ThreeDisplaySA->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    42. ThreeDisplaySA->ensureWidgetVisible( ThreeDisplay );
    43. dock->setWidget( ThreeDisplaySA );
    44. addDockWidget(Qt::BottomDockWidgetArea, dock);
    45. viewMenu->addAction(dock->toggleViewAction());
    46. }
    To copy to clipboard, switch view to plain text mode 
    Regards
    Last edited by marcel; 6th August 2007 at 23:12.

Similar Threads

  1. Replacing Central Widget in Designer
    By Max Yaffe in forum Qt Tools
    Replies: 2
    Last Post: 11th July 2007, 11:41
  2. paint central widget of a QMainWindow???
    By Shuchi Agrawal in forum Newbie
    Replies: 3
    Last Post: 17th January 2007, 08:02
  3. Pin/Unpin Dock Widget
    By charlesD in forum Newbie
    Replies: 1
    Last Post: 21st June 2006, 06:57
  4. Central Widget of QMainWindow
    By sumsin in forum Qt Programming
    Replies: 3
    Last Post: 13th March 2006, 18:32
  5. [Qt 4.1.0] Split a widget on demand
    By Townk in forum Qt Programming
    Replies: 3
    Last Post: 17th February 2006, 14:16

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.