Results 1 to 3 of 3

Thread: Surprising problem when making a subclass of a subclass of QApplication

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Apr 2013
    Posts
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Post Surprising problem when making a subclass of a subclass of QApplication

    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();
    }
    Attached Files Attached Files
    Last edited by latinum; 10th April 2013 at 14:12. Reason: spelling corrections

Similar Threads

  1. Replies: 4
    Last Post: 14th September 2012, 18:13
  2. KDChart: add horizontal lines (levels/markers)
    By galrub in forum KDE Forum
    Replies: 0
    Last Post: 5th August 2012, 19:02
  3. type casting 5 levels down no error but not proper
    By sujan.dasmahapatra in forum Qt Programming
    Replies: 4
    Last Post: 29th April 2012, 15:04
  4. Nested tables (different columns at sub levels)
    By lfiedler in forum Qt Programming
    Replies: 0
    Last Post: 18th March 2011, 17:26
  5. Subclass Problem
    By rleojoseph in forum Newbie
    Replies: 21
    Last Post: 4th February 2011, 07:43

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.