Results 1 to 3 of 3

Thread: Subclass QStatusBar

  1. #1
    Join Date
    Nov 2008
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Subclass QStatusBar

    Hello all,

    I have main window and I would like to create my own status bar for this window. So the obvious way of doing it is to subclass QStatusBar and create my own class base on that.

    So I have a simple class
    Qt Code:
    1. class MyStatusBar : public QStatusBar
    2. {
    3. // constructor and destructor here
    4. };
    To copy to clipboard, switch view to plain text mode 
    Then in MyMainWindow constructor I set status bar like this
    Qt Code:
    1. this->setStatusBar(myStatusBar);
    To copy to clipboard, switch view to plain text mode 
    However, if I start application I get following error
    undefined symbol: _ZN10QStatusBar9showEventEP10QShowEvent
    My question is
    Is it possible to subclass QStatusBar? There is nothing about it in Qt manuals. If yes, should I implement some virtual functions, because it looks like application cannot find function body (or maybe I'm wrong).

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Subclass QStatusBar

    you can subclass QStatusBar
    Qt Code:
    1. #include <QMainWindow>
    2. #include <QStatusBar>
    3.  
    4. class MyStatusBar : public QStatusBar
    5. {
    6. public:
    7. MyStatusBar(QWidget *parent = 0) : QStatusBar(parent) {}
    8. };
    9.  
    10. class Test: public QMainWindow
    11. {
    12. public:
    13. Test(QWidget *parent = 0);
    14. };
    15. ...
    16. Test::Test(QWidget *parent)
    17. : QMainWindow(parent)
    18. {
    19. setStatusBar(new MyStatusBar);
    20. }
    To copy to clipboard, switch view to plain text mode 
    works fine. could you show compilable example?
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Nov 2008
    Posts
    17
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Subclass QStatusBar

    Hmmm...it looks like I have some internal problem. Because simple example works fine.

Similar Threads

  1. QSqlQueryModel write subclass
    By skuda in forum Qt Programming
    Replies: 6
    Last Post: 29th October 2007, 16:18
  2. Replies: 9
    Last Post: 29th March 2007, 13:41
  3. expanding to the max. available space in a QStatusBar
    By momesana in forum Qt Programming
    Replies: 1
    Last Post: 11th November 2006, 20:02
  4. QT4: Sorting in QTreeWidget (subclass)
    By Michiel in forum Qt Programming
    Replies: 21
    Last Post: 29th March 2006, 18:08
  5. QFrame subclass does not reparent
    By high_flyer in forum Qt Programming
    Replies: 2
    Last Post: 21st March 2006, 22:15

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.