PDA

View Full Version : QDockWidget move problem when using custom title widget



alexi_nedo
6th September 2010, 12:25
Hi,
I want to create a dock widget with a custom title widget. That custom title widget has my own icons (maximize, minimize, close etc). A snapshot of the dock widget is attached.

Source code is simply like that:



QDockWidget *dock = new QDockWidget("name", parent);
MyDockTitle * titleWidget = new MyDockTitle(dock);
dock->setTitleBarWidget(titleWidget);

When I run the program, dock widget is shown appropriately but unfortunately I can not move the dock widget (it is in floating state). What can be the problem?

P.S. When I dont use custom title widget, I can move dock widget.

Thanks...

norobro
7th September 2010, 23:44
From the docs (http://doc.qt.nokia.com/4.6/qdockwidget.html#setTitleBarWidget):
Mouse events that are not explicitly handled by the title bar widget must be ignored by calling QMouseEvent::ignore(). These events then propagate to the QDockWidget parent, which handles them in the usual manner, moving when the title bar is dragged, docking and undocking when it is double-clicked, etc.

alexi_nedo
13th September 2010, 13:25
Thank you very much for your answer. Can you explain how can I call
QMouseEvent::ignore() by giving a piece of code.
I tried the following but the mouseMoveEvent never reaches to parent widget so I can not move the widget.


void MyDockTitle::mouseMoveEvent ( QMouseEvent * event )
{
qDebug()<< "mouseMoveEvent";
event->ignore();
}

Thanks in advance...