Results 1 to 11 of 11

Thread: Q_OBJECT error

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2008
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Q_OBJECT error

    Hey, my code compiles fine but I cannot connect my own functions to a signal. Is the reason because i have not put the Q_OBJECT macro in the class header file for the window?

    if so when i do put this macro in i get 2 errors.

    make: *** [debug] Error 2
    make[1]: *** [debug\buttonTest.exe] Error 1

    I was hoping if i fixed this then i would be able to connect signals to my own functions.

    -----------------

    Qt Code:
    1. class Window : public QWidget
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. Window(QWidget *parent = 0)
    7. {
    8. button = new QPushButton("Increment", this);
    9. lcd = new QLCDNumber(2, this);
    10. slider = new QSlider(Qt::Horizontal);
    11. slider->setRange(0,99);
    12. slider->setValue(0);
    13.  
    14. QObject::connect(slider, SIGNAL(valueChanged(int)),
    15. this, SLOT(Update(int)));
    16. //lcd, SLOT(display(int)));
    17.  
    18. QVBoxLayout *layout = new QVBoxLayout;
    19. layout->addWidget(slider);
    20. layout->addWidget(lcd);
    21. layout->addWidget(button);
    22. this->setLayout(layout);
    23.  
    24. }
    25.  
    26. private slots:
    27. void Update(int i)
    28. {
    29. lcd->display(i);
    30. }
    31.  
    32.  
    33. private:
    34. QPushButton *button;
    35. QLCDNumber *lcd;
    36. QSlider *slider;
    37. };
    To copy to clipboard, switch view to plain text mode 


    Qt Code:
    1. //.pro file
    2. TEMPLATE = app
    3. TARGET = buttonTest
    4. QT += core \
    5. gui
    6. HEADERS += buttontest.h
    7. SOURCES += main.cpp \
    8. buttontest.cpp
    9. FORMS += buttontest.ui
    10. RESOURCES +=
    To copy to clipboard, switch view to plain text mode 
    Last edited by Toshikazu; 27th May 2008 at 15:07.

Similar Threads

  1. QPSQL problem
    By LoneWolf in forum Installation and Deployment
    Replies: 60
    Last Post: 4th November 2009, 14:22
  2. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  5. qt 4.2.2 install on aix
    By try to remember in forum Installation and Deployment
    Replies: 2
    Last Post: 28th March 2007, 12:19

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.