Results 1 to 3 of 3

Thread: help!!!

  1. #1
    Join Date
    Jan 2008
    Posts
    39
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanks
    1

    Unhappy help!!!

    Hi, i am new in qt4, i am converting a program that i was develop a few timne ago, and i am having problem now when subclassing a class that a was develop before.
    #include <QObject>
    class a : public QObject
    {
    public:
    a();
    Q_OBJECT
    QString get_b(){return b}:
    private:
    QString b;
    }
    now when i am tryng to use class a
    //======================
    include "a.h"
    class b: public a
    {
    public:
    b();
    set_a();//error "b is private from this context"!!!!!!
    private:
    QList<a> list;//error in compiler
    }
    //===================================
    a little help will awesome
    thx!

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows
    Thanks
    8
    Thanked 133 Times in 128 Posts

    Default Re: help!!!

    move the Q_OBJECT macro in the private section of the class a

    Qt Code:
    1. class a :public QObject
    2. {
    3. Q_OBJECT
    4. public:
    5. ...
    6. ..
    7. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jun 2009
    Location
    Zhengzhou, China
    Posts
    16
    Qt products
    Qt4
    Platforms
    MacOS X
    Thanks
    2

    Default Re: help!!!

    I think Q_OBJECT should be in the private section of class a, as it says in Qt document:

    The Q_OBJECT macro must appear in the private section of a class definition that declares its own signals and slots or that uses other services provided by Qt's meta-object system.

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
  •  
Qt is a trademark of The Qt Company.