You can achieve the same kind of functionality with QSplitter, whose orientation is vertical, see QSplitter::setOrientation().
You can achieve the same kind of functionality with QSplitter, whose orientation is vertical, see QSplitter::setOrientation().
J-P Nurmi
QSplitter will not do the trick I need. I'm sure of that. I need QDockWidget. Is there any way to remove the title bar??
After taking a look at src/gui/widget/dockwidget.cpp, QDockWidgetPrivate::relayout(), I'm afraid it's not possible. The dock widget title bar is not a separate widget. The dockwidget's private layouting mechanism just reserves some space for the title.
You can set dock widget's features to QDockWidget::NoDockWidgetFeatures to make buttons disappear. You can return return 0 for QStyle::pixelMetric(QStyle::PM_DockWidgetTitleMarg in) to make it thinner than normal. But it will still calculate some minimum height based on font metrics. You can even construct a font with point size 1 (font's point size must be greater than 0) to make the fontmetrics return smaller size, but the title will still appear...
Last edited by jpn; 23rd August 2006 at 13:48. Reason: Disabled smilies
J-P Nurmi
So, how does this differ from having dock widgets with no title bars?
Qt Code:
#include <QtGui> { public: { // just some 2 dummy example widgets to fill splitters with for (int i = 0; i < 10; ++i) for (int r = 0; r < table->rowCount(); ++r) for (int c = 0; c < table->columnCount(); ++c) label->setAlignment(Qt::AlignCenter); v->addWidget(list); v->addWidget(table); h->addWidget(v); h->addWidget(label); setCentralWidget(h); } }; int main(int argc, char *argv[]) { MainWindow w; w.show(); return a.exec(); }To copy to clipboard, switch view to plain text mode
J-P Nurmi
Thank you for all your help. I'll try using qsplitter and see if it's ql.
Ok. Splitter isn't ql because I do need some of dockWidget's features. I don't need to remove the title bar anymore (I fixed this problem), but I don't know that if I can draw a dockwidgetHandle like QToolbarHandle ??? in my own Qstyle
We could be more helpful if you told us exactly what features do you need.Originally Posted by moowy
Sure, you can draw anything you want with styles, you will just have to provide proper style options. See QStyle::draw*() docs. You will have to implement the behaviour yourself. Drawing a handle won't bring you any functionality..I don't need to remove the title bar anymore (I fixed this problem), but I don't know that if I can draw a dockwidgetHandle like QToolbarHandle ??? in my own Qstyle
Are you aware that you can place any widget in a tool bar? Maybe this is more what you're after?
J-P Nurmi
Can you maybe help me with the apropriate PE_primitiveElement to use to draw onto QDockWidget titleBar or maybe CE_controlElement ??
The handle is just for good looks .
The features I need are float and movable dockwidget
Override QDockWidget::paintEvent(). Call base class implementation first so that the dock widget gets drawn normally. Then draw your custom thing on top. Take a look at src/gui/widget/qtoolbarhandle.cpp: especially QToolBarHandle::paintEvent() and getStyleOption().
Qt Code:
{ // let the base class draw first // maybe use QStyle::pixelMetric() for these? static const int WIDTH = 10; static const int HEIGHT = 20; // draw some kind of handle QStyleOption opt; opt.initFrom(this); }To copy to clipboard, switch view to plain text mode
Edit: What comes to customizing widgets, checking out things done in Qt sources is definitely the most powerful way. It's simply impossible to cover every little detail in the docs. Qt sources are readable and understandable, so use the power of the sources! :)
Last edited by jpn; 25th August 2006 at 08:43. Reason: added a note
J-P Nurmi
Somehow this doesn't do the trick. I already have installed an eventFilter(paint event) on the qdockwidget and I applied the code to it but it doesn't show. Any other ideas??
I will try using the CE_DockWidgetTitle. I can't believe that I ddin't see it in the QStyle
Last edited by moowy; 25th August 2006 at 09:40.
Painting in an event filter is a bit problematic because the event goes FIRST through the filter and THEN to the base class (assuming that the event filter doesn't filter it out). So basically the base class draws over anything you had drawn in the event filter. This kind of painting is possible in event filter only by doing some ugly tricks. Basically you have to deliver the event to the receiver widget by hand and then do the custom painting afterwards. And you will also have to temporarily remove the event filter to avoid an infinite loop.Originally Posted by moowy
Qt Code:
// this is inside an event filter where event type is a paint event.. // remove the event filter during sending // the paint event to avoid an infinite loop widget->removeEventFilter(this); // send the event and let the widget to draw itself first // restore the event filter widget->installEventFilter(this); // draw your custom things here .... // be sure to return true so that the widget doesn't // receive this paint event and paint itself over again return true;To copy to clipboard, switch view to plain text mode
So, I recommend you to simply subclass QDockWidget and override paintEvent()... it will be much simplier and less error prone..
J-P Nurmi
I have another problem conserning QDockWidget. In my workspace i have tvo dockwidgets and one other widget. The problem is that these two widgets have their own PE_IndicatorDockWidgetResizeHandle and I only need one. I know how to disable them both but i don't know how to disable just one.
i tried this code but it doesn't work (if i remove the part with the objectName it disables the both of them)
if (((widget->inherits("QDockWidgetSeparator")) || (widget->inherits("QDockSeparator"))) && (widget->objectName()=="name"))
{
widget->setAttribute(Qt::WA_Disabled);
}
Bookmarks