PDA

View Full Version : QDockWidget and setting/unsetting titleBarWidget



gwiazdorrr
11th March 2011, 13:21
Hi, I'm working on dock-based application and recently I've decided to use my own titleBarWidgets. It works great, but the downfall is we lose native fell & look when going into undocked state (at least on Win7).

So what I was trying to do was to connect to topLevelChanged signal and then in slot either set my custom widget as titleBarWidget (going into docked state) or set titleBarWidget to 0 (undocked), thus returning native window decorations. So code looks roughly like this:


QWidget* titleBar;
...
QObject::connect( this, SIGNAL(topLevelChanged(bool)), this, SLOT(setUseNativeTitleBar(bool)) );
...
void setUseNativeTitleBar(bool native)
{
if ( native ) {
// restoring native
setTitleBarWidget(0);
} else {
// using custom
setTitleBarWidget(titleBar);
}
}

Now it seems to work just fine, but more than often it results in assertion failure during undocking (especially when stacking widgets horizontally):

ASSERT: "!(item.flags & QDockAreaLayoutItem::GapItem)" in file widgets\qdockarealayout.cpp, line 1082

So my question is: is changing titleBarWidget in this manner even possible? If so, how to get it working?

Oh yes, and I'm using Qt 4.7.1.

neFAST
15th March 2011, 07:12
I have the very same issue. Could someone from QT confirm doing this is wrong?

wang9658
30th January 2012, 12:45
I have exact same issue.

ASSERT: "!(item.flags & QDockAreaLayoutItem::GapItem)" in file c:\ndk_buildrepos\qt-desktop\src\gui\widgets\qdockarealayout.cpp, line 1082

I'm working with Qt 4.7.4 on WinXP.

This is a very old thread. Had you resolved this issue?

gwiazdorrr
30th January 2012, 19:58
Unfortunately not. The error was nested too deep inside Qt code. Because of that I switched to non-native titlebars.