PDA

View Full Version : QDockWidget border



QPlace
12th July 2009, 17:28
How to set up DockWidget so it has visible border around the edges?

wysota
13th July 2009, 10:15
Add a frame to it or subclass it and do the drawing yourself.

QPlace
13th July 2009, 14:03
I am using the frame currently, with less then appealing visual results. I am trying to avoid widget custom painting at this stage of my project (and, khm-khm, knowledge of Qt). My question can be redefine as broader one:

I re-read documentation on QWidget and from what I understood there is no such thing as "border" or "frame" property for a widget. The only reference is the flag Qt::MSWindowsFixedSizeDialogHint for top-level widgets only. This flag does exactly what I want, i.e drawing a thin line around the widget border. Take QPushButton for example, it has that type of border around it. But what is interesting to me is that I can't find exposed property for this widget where I can change a width of this frame. QTreeView, on the other hand, has (or is inhered from?) QFrame that is used as a widget boder and I can change border properties of QTreeView in design time.

I am hoping that I missed something very basic in Qt, so my question is:
In general - how to add/remove/edit "border" or "frame" of the stock widgets (buttons, lists, dockwidgets)? Or is it even possible and is there any other solution besides subsclassing and painting this basic stuff myself?

And, regarding QDockWidget - isn't it strange that the default view of that widget has dialog caption for displaying the titiel and dragging, but no border around it?

wysota
13th July 2009, 14:14
You can design your own style or implement a style proxy that will introduce such changes but this involves drawing as well. I see no other choice.

chezifresh
27th October 2009, 01:16
Is there an easy way to have a dock widget tear off into a QDialog?

Floating QDockAreas are kind of a pain to work with, if I could tear it off into a dialog that would be sweet. (while still being able to move it from one dock area to another...)

Phlucious
25th May 2012, 02:28
I know this is an old thread, but my Google searches have brought me back to this page several times, so maybe we can help future searchers.

I recently stumbled over the solution the OP was looking for here:
http://doc.qt.nokia.com/4.7-snapshot/stylesheet-examples.html#customizing-qmainwindow

You're looking for the QMainWindow::separator{} style sheet. For example, in mainwindow.cpp:

myMainWindow->setStyleSheet(
"QMainWindow::separator {
background: rgb(200, 200, 200);
width: 2px;
height: 2px;
}");