Results 1 to 4 of 4

Thread: Simple problem

  1. #1
    Join Date
    Jun 2008
    Posts
    9
    Thanks
    9
    Platforms
    Unix/X11 Windows

    Default Simple problem

    Hello!
    I just started learning qt and I have some questions. I've write a simple program but something is wrong. When the button is clicked() it should write a value on the LCD Screen but there is only a warning: ''Object::connect: No such slot QLCDNumber::display(5)'' ,but I've read that there is a slot like 'display(int num)'

    Qt Code:
    1. #include <QApplication>
    2. #include <QFont>
    3. #include <QPushButton>
    4. #include <QWidget>
    5. #include <QLCDNumber>
    6.  
    7. class MyWidget : public QWidget
    8. {
    9. public:
    10. MyWidget(QWidget *parent = 0);
    11. };
    12.  
    13. MyWidget::MyWidget(QWidget *parent)
    14. : QWidget(parent)
    15. {
    16.  
    17. setFixedSize(200,120);
    18.  
    19. QPushButton *quit = new QPushButton(tr("Click"),this);
    20. QLCDNumber *lcd = new QLCDNumber(2,this);
    21. quit -> setGeometry(62,40,75,30);
    22. quit -> setFont(QFont("Times", 18, QFont::Black, true));
    23. connect(quit,SIGNAL(clicked()),lcd,SLOT(display(5)));
    24.  
    25. }
    26.  
    27. int main(int argc, char *argv[])
    28. {
    29. QApplication app(argc,argv);
    30.  
    31. MyWidget widget;
    32. widget.show();
    33.  
    34. return app.exec();
    35. }
    To copy to clipboard, switch view to plain text mode 

    Thanks, for the answers.

  2. #2
    Join Date
    Jun 2008
    Location
    Glenwood, NJ USA
    Posts
    32
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Simple problem

    I am a beginner myself but in the reading I have been doing, it was made clear that you cannot declare the parameter names or pass values in the SLOT() of a connect(). You need to change your SLOT(display(5)) to SLOT(display(int)). This slot displays the property which reflects the current value stored by QLCDNumber
    Last edited by awhite1159; 21st June 2008 at 13:08.

  3. The following user says thank you to awhite1159 for this useful post:

    s410i (28th August 2008)

  4. #3
    Join Date
    Jun 2008
    Posts
    35
    Thanks
    5
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: Simple problem

    I 'd the same problem but it has been solved .
    You can find "How to make your Slots " :

    http://www.qtcentre.org/forum/f-qt-p...lot-13980.html

  5. The following user says thank you to Fatla for this useful post:

    s410i (28th August 2008)

  6. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,360
    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

  7. The following user says thank you to wysota for this useful post:

    s410i (28th August 2008)

Similar Threads

  1. Simple QtPainter problem
    By rishid in forum Qt Programming
    Replies: 3
    Last Post: 5th February 2008, 21:00
  2. Simple Problem with QFont (point size)
    By mtrpoland in forum Newbie
    Replies: 4
    Last Post: 31st December 2007, 16:49
  3. Problem with simple Model-View in Qt4.3
    By ccf_h in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2007, 18:57
  4. Replies: 2
    Last Post: 19th May 2007, 18:25
  5. Very simple problem with QServerSocket and Qsocket
    By eter in forum Qt Programming
    Replies: 2
    Last Post: 4th November 2006, 08:07

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.