PDA

View Full Version : QDockWidget custom titlebar removes focus of application



Alundra
18th November 2014, 04:39
Hi,
I have a custom titlebar in a custom QDockWidget to have a better undock behavior and possibilities.
All works good, the only problem is when I init one QMainWindow with dock inside, the focus of the QMainWindow is removed.
Here the code of my custom QDockWidget :


CDockWidget::CDockWidget( const QString& Title, QWidget* Parent ) :
QDockWidget( Title, Parent )
{
m_Titlebar = new CTitlebarWidget( this );
setTitleBarWidget( m_Titlebar );
}

bool CDockWidget::event( QEvent* event )
{
switch( event->type() )
{
case QEvent::WindowTitleChange :
{
m_Titlebar->SetTitle( windowTitle() );
return true;
}

case QEvent::NonClientAreaMouseButtonDblClick :
{
if( isMaximized() )
showNormal();
else
showMaximized();
return true;
}
}
return QDockWidget::event( event );
}

If I comment the constructor code and the switch in the event function, the focus is not removed.
How can I solve this problem ?
Thanks for the help