Results 1 to 3 of 3

Thread: QDockWidget separator

  1. #1

    Default QDockWidget separator

    Hi all,
    i'm working with qt 4.8.4.
    I need to style separator of QDockWidget, i know that with QSS QMainWindow::separator i can style separator. It works well only when QDockWidget hasn't fixed size.
    Qt Code:
    1. qDock->widget()->setSizePolicy(QSizePolicy::Policy::Minimum,QSizePolicy::Policy::Minimum);
    2. qDock->widget()->setMinimumHeight(0);
    3. qDock->widget()->setMaximumHeight(5);
    To copy to clipboard, switch view to plain text mode 
    In this example separator have magenta color:
    Color.jpg



    But if QDockWidget have fixed size, the color of separator is always default system.
    Qt Code:
    1. qDock->widget()->setSizePolicy(QSizePolicy::Policy::Minimum,QSizePolicy::Policy::Minimum);
    2. qDock->widget()->setMinimumHeight(0);
    3. qDock->widget()->setMaximumHeight(0);
    To copy to clipboard, switch view to plain text mode 
    NotColored.jpg

    How can i mantain color also with fixed size?

    Thank you

    Marco

  2. #2
    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: QDockWidget separator

    Your images do not clearly show what you mean. There is no obvious QDockWidget in either.

    The separator handle goes between dock widgets, or between dock widgets and the central widget, and allows you to resize the adjoining areas. Clearly that is not possible if the dock widget is fixed size. If it is not possible to resize a dock widget/dock widget area then there is no separator handle and no background color for it, although the space is still reserved.

    Experiment with this code and move the resizable dock 2 around to see where the handles become visible/invisible.
    Qt Code:
    1. #include <QtGui>
    2.  
    3. class MainWindow: public QMainWindow {
    4. Q_OBJECT
    5. public:
    6. MainWindow(QWidget *p = 0): QMainWindow(p) {
    7. setCentralWidget(new QTextEdit(this));
    8. setStyleSheet("QMainWindow::separator { background-color: red; width: 30; height: 30px; }");
    9.  
    10. QDockWidget *dock = new QDockWidget(this);
    11. QLabel *label = new QLabel("Dock 1", this);
    12. label->setFixedSize(50, 50);
    13. dock->setWidget(label);
    14. addDockWidget(Qt::TopDockWidgetArea, dock);
    15.  
    16. dock = new QDockWidget(this);
    17. label = new QLabel("Dock 2", this);
    18. dock->setWidget(label);
    19. addDockWidget(Qt::TopDockWidgetArea, dock);
    20. }
    21. };
    22.  
    23. int main(int argc, char *argv[]) {
    24. QApplication app(argc, argv);
    25. MainWindow m;
    26. m.show();
    27. return app.exec();
    28. }
    29. #include "main.moc"
    To copy to clipboard, switch view to plain text mode 

  3. #3

    Default Re: QDockWidget separator

    I try to explain better.
    In the image, red rectangle is only to show which dockBar that we are talking about.

    White region inside red rectangle is dock widget titlebar that i have replaced with custom widget:
    Qt Code:
    1. qDock->setTitleBarWidget(myCustomTitlebar);
    To copy to clipboard, switch view to plain text mode 

    Instead dock widget is setted with height = 0, so you can only view titlebar.

    I'm agree with you that if dockWidget is fixed the user won't need separator. But why QT reserve same space with default color instead of drawing nothing or same sparator but disabled?
    PS: i've already try to style separator with:
    QMainWindow::separator::disable but nothing change.

    Thank you

    Marco

Similar Threads

  1. modifications of decimal separator
    By 21did21 in forum Qwt
    Replies: 2
    Last Post: 2nd August 2011, 21:41
  2. Replies: 1
    Last Post: 7th December 2010, 21:46
  3. Separator in box layout
    By drhex in forum Qt Programming
    Replies: 1
    Last Post: 30th September 2009, 22:36
  4. Separator in context menu
    By schall_l in forum Qt Programming
    Replies: 3
    Last Post: 18th June 2009, 17:09
  5. separator in QComboBox
    By dyams in forum Qt Programming
    Replies: 3
    Last Post: 7th March 2008, 09:56

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.