Results 1 to 4 of 4

Thread: Trouble with QLabel

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

    Exclamation Trouble with QLabel

    I'm having troubles with QLabel. This is the code from the book :
    Qt Code:
    1. // helloWorld/main.cpp
    2. #include <QApplication>
    3. #include <QLabel>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. QLabel label("Hello World");
    9. label.show();
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    main.cpp:2:24: error: QApplication: No such file or directory
    main.cpp:3:18: error: QLabel: No such file or directory
    main.cpp: In function 'int main(int, char**)':
    main.cpp:7: error: 'QApplication' was not declared in this scope
    main.cpp:7: error: expected `;' before 'a'
    main.cpp:8: error: 'QLabel' was not declared in this scope
    main.cpp:8: error: expected `;' before 'label'
    main.cpp:9: error: 'label' was not declared in this scope
    main.cpp:10: error: 'a' was not declared in this scope
    main.cpp: At global scope:
    main.cpp:5: warning: unused parameter 'argc'
    main.cpp:5: warning: unused parameter 'argv'
    make: *** [main.o] Error 1

    Than I change in header QApplication to qapplication.h and QLabel to qlabel.h
    Qt Code:
    1. // helloWorld/main.cpp
    2. #include <qapplication.h>
    3. #include <qlabel.h>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. QApplication a(argc, argv);
    8. QLabel label("Hello World");
    9. label.show();
    10. return a.exec();
    11. }
    To copy to clipboard, switch view to plain text mode 
    main.cpp: In function 'int main(int, char**)':
    main.cpp:8: error: no matching function for call to 'QLabel::QLabel(const char [12])'
    /usr/lib/qt/include/qlabel.h:163: note: candidates are: QLabel::QLabel(const QLabel&)
    /usr/lib/qt/include/qlabel.h:66: note: QLabel::QLabel(QWidget*, const QString&, QWidget*, const char*, uint)
    /usr/lib/qt/include/qlabel.h:64: note: QLabel::QLabel(const QString&, QWidget*, const char*, uint)
    /usr/lib/qt/include/qlabel.h:62: note: QLabel::QLabel(QWidget*, const char*, uint)
    make: *** [main.o] Error 1

    Can somebody tell me what is wrong with this?

  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: Trouble with QLabel

    looks like that you didn't specify LD_LIBRARY_PATH for Qt.

  3. #3
    Join Date
    Aug 2009
    Posts
    47
    Thanks
    6
    Thanked 1 Time in 1 Post
    Qt products
    Qt4 Qt/Embedded PyQt3 PyQt4
    Platforms
    Unix/X11 Symbian S60

    Default Re: Trouble with QLabel

    use like

    QLabel label;
    label.setText("hai");
    label.show();

  4. #4
    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: Trouble with QLabel

    what is difference? the code wich specified author is correct.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

Similar Threads

  1. Replies: 3
    Last Post: 17th July 2008, 07:43
  2. QLabel ScaledContents ignored by style sheet?
    By WinchellChung in forum Newbie
    Replies: 3
    Last Post: 27th February 2008, 14:50
  3. QLabel size policy
    By Caius Aérobus in forum Qt Programming
    Replies: 3
    Last Post: 7th December 2007, 17:57
  4. Trouble placing QLabel on top ofQGLWidget
    By JimDaniel in forum Qt Programming
    Replies: 1
    Last Post: 8th October 2007, 23:48
  5. QScrollArea display custom QLabel
    By spawnwj in forum Qt Programming
    Replies: 6
    Last Post: 6th December 2006, 03:38

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.