Hello,
I am trying to subclass QApplication into two levels but I have discovered some amazing behaviour. My OS is Centos 6.3 and I am using qt4.7 as made available via the atrpms repo mentioned on the Centos website. The entire test jig, a suitable makefile and the gdb backtrace of the failure can be seen in the attached test.cpp file.
My test application itself (also shown below) draws a single button in a window. The button has a tooltip.
When my QApplication derived class is an immediate subclass of QApplication, the application works as expected. When I hover over the button and wait a bit, I see my tool tip.
However, if my test app is a subclass of a subclass of QApplication, the story is very different. The application starts fine but when I hover over the button and wait the popup delay time, the popup does not appear and the app dies somewhere in code relating to X (XSetCommand) !
Interestingly, this behaviour is not observed on Centos 5. In fact it also doesn't happen when I run my Centos 6-compiled test binary on Centos 5 'as is'.
I am completely stumped by what could cause this weird behaviour but its pretty easy to prove. Can anybody give me any insight into what might be the cause ??
Thanks in advance.
#include <QtGui/qtoolbutton.h>
#include <QtGui/qapplication.h>
//
#define MAKE_IT_DIE 1
class A_App : public QApplication
{
public:
A_App(int argc, char** argv) : QApplication(argc, argv)
{
}
};
#if MAKE_IT_DIE
typedef A_App SUPER;
#else
typedef QApplication SUPER;
#endif
class B_App : public SUPER
{
public:
B_App(int argc, char** argv) : SUPER(argc, argv)
{
}
};
int
main(int argc, char** argv)
{
B_App app(argc, argv);
QToolButton* f = new QToolButton;
f->show();
f->setToolTip("HELLO WORLD");
return app.exec();
}
Bookmarks