Results 1 to 8 of 8

Thread: begineer in QT

  1. #1
    Join Date
    Aug 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default begineer in QT

    hi to all
    I m trying to create a form and on click on a button that data from QLine Edit should be submitted to the Database . but that is not working .

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: begineer in QT

    Could you provide any details on what you actually did?

  3. #3
    Join Date
    Aug 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: begineer in QT

    I have created 3 files as app.h,app.cpp,main.cpp
    to create a form with submit and cancel button .
    But after compliling it is showing:--

    "app1.h:13: Error: Class contains Q_OBJECT macro but does not inherit from QObje
    t"

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: begineer in QT

    So did you make it inherit QObject?

  5. #5
    Join Date
    Aug 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: begineer in QT

    i m writing the code as in:-

    #ifndef APP1_H
    #define APP1_H

    class QPushButton;
    class QLineEdit;
    class QLabel;
    class QGridLayout;
    class QWindow;


    class app1
    {
    Q_OBJECT
    public:
    app1(QWidget *parent=0);


    private:
    QLabel *cust_id;
    QLineEdit *tcust;
    QPushButton *sub;
    QPushButton *can;
    QGridLayout *lay2;
    QWidget *window;

    };
    #endif

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: begineer in QT

    But why did you use Q_OBJECT without inheriting QObject? The compiler told you what is wrong. Either remove the macro or inherit QObject.

  7. #7
    Join Date
    Aug 2007
    Posts
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: begineer in QT

    but i m refering a book as "c++ GUI Programming with QT -4.1.1"
    its is given there and more over.
    i have created a form in which there was no problem but now its is giving that Error

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: begineer in QT

    I'm sure the book doesn't tell you to create a class which doesn't inherit QObject and use Q_OBJECT macro with it. You probably wanted:
    Qt Code:
    1. class app1 : public QWidget {
    2. //...
    3. };
    To copy to clipboard, switch view to plain text mode 

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.