QDockWidget: Debugging crash
Hi
I am porting Kalzium from Qt3 to Qt4. The last Qt3-class which needed porting is the toolbox, which is in a QDockWindow (Qt3) and now in a QDockWidget (Qt 4.1).
This is a screenshot of the Qt3.5-version. I am talking about the widget on the left.
http://edu.kde.org/kalzium/pics/screen1.png
Everything looks fine so far, but when I click on the little area on top of the window (directly over the word "Overview") it crashes. You can read the sourcecode here: http://websvn.kde.org/trunk/KDE/kdee...94861&view=log
The QDockWidget is created here:
Code:
m_dockWin->setWidget( m_toolbox );
m_dockWin->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
this is the KMainWindow. The widgets in the QToolBox work as expected, the crash only happens if you click on the small area.
Ideas?
Re: QDockWidget: Debugging crash
Isn't a dockwidget without parent bad? I can imagine that the dockwidget tries to communicate with the mainWindow when you click on the header for dock/undock purposes.
Edit:
At least, you miss some addDockWidget() calls.
Re: QDockWidget: Debugging crash
Between line 1 ans 2 insert:
Code:
Q_CHECK_PTR(m_toolBox);
In line 3 insert:
Code:
Q_CHECK_PTR(m_dockWin);
so we can see if pointer are ok. If that is ok, than we'll move forward.
Re: QDockWidget: Debugging crash
Did you insert Q_CHECK_PTR as I said?
Re: QDockWidget: Debugging crash
I still think that the parent() of the QDockWidget is 0.
Re: QDockWidget: Debugging crash
Re: QDockWidget: Debugging crash
Either this or the dock widgets should be added later using addDockWidget. I think this sets the parent too.
Re: QDockWidget: Debugging crash
This is the current code, still crashing. As soon as I make the m_dockWin a child of "this" it is *in* the mainwindow. So that cannot be right.
Code:
Q_CHECK_PTR( m_dockWin );
Q_CHECK_PTR( m_toolbox );
m_dockWin->setWidget( m_toolbox );
m_dockWin->setAllowedAreas( Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea );
I noticed this in the shell when executing Kalzium
Quote:
QLayout::addChildWidget: QToolBox "" in wrong parent; moved to correct parent
class Kalzium is:
Code:
Kalzium::Kalzium()
: KMainWindow( 0, "Kalzium" )
{
I don't know the check-pointer-macro, but I don't see any information in the shell. Is this supposed to help in gdb?
Re: QDockWidget: Debugging crash
Like axeljaeger said, you should also use addDockWidget().
Re: QDockWidget: Debugging crash
Ok, I just debugged a little more. The problem seems to be that KMainWindow does *not* inherit from QMainWindow but from Q3MainWindow. And Q3MainWindow doesn't know anything about QDockWidget but only about QDockWindow. Therefore, somewhere in the Q3Compatlib it crashes.
So somebody needs to port KMainWindow of KDE4 first.