PDA

View Full Version : QDockWidget separator



ruscoff
22nd October 2013, 15:19
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.


qDock->widget()->setSizePolicy(QSizePolicy::Policy::Minimum,QSizePo licy::Policy::Minimum);
qDock->widget()->setMinimumHeight(0);
qDock->widget()->setMaximumHeight(5);

In this example separator have magenta color:
9708



But if QDockWidget have fixed size, the color of separator is always default system.


qDock->widget()->setSizePolicy(QSizePolicy::Policy::Minimum,QSizePo licy::Policy::Minimum);
qDock->widget()->setMinimumHeight(0);
qDock->widget()->setMaximumHeight(0);

9709

How can i mantain color also with fixed size?

Thank you

Marco

ChrisW67
23rd October 2013, 04:59
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.


#include <QtGui>

class MainWindow: public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *p = 0): QMainWindow(p) {
setCentralWidget(new QTextEdit(this));
setStyleSheet("QMainWindow::separator { background-color: red; width: 30; height: 30px; }");

QDockWidget *dock = new QDockWidget(this);
QLabel *label = new QLabel("Dock 1", this);
label->setFixedSize(50, 50);
dock->setWidget(label);
addDockWidget(Qt::TopDockWidgetArea, dock);

dock = new QDockWidget(this);
label = new QLabel("Dock 2", this);
dock->setWidget(label);
addDockWidget(Qt::TopDockWidgetArea, dock);
}
};

int main(int argc, char *argv[]) {
QApplication app(argc, argv);
MainWindow m;
m.show();
return app.exec();
}
#include "main.moc"

ruscoff
23rd October 2013, 08:22
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:


qDock->setTitleBarWidget(myCustomTitlebar);


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