Results 1 to 16 of 16

Thread: C++ GUI Programming

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2017
    Posts
    19
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default C++ GUI Programming

    I am new to Qt programming, with good understanding of C++.
    I bought Prentice Hall Book, "C++ GUI Programming with Qt 4, Second Edition" by Blanchette and Summerfield. (2008 Published)
    I have downloaded this books source code files from the book publisher's web site.

    I have downloaded and installed on Windows, latest trial version of Qt free for about one month.

    Following is above book's first program:

    // hello.cpp
    #include <QApplication>
    #include <QLabel>

    int main(int argc, char *argv[])
    {
    QApplication app(argc, argv);
    QLabel *label = new QLabel("Hello Qt!");
    label->show();
    return app.exec();
    }

    Qt is saying No such file or directory for both QApplication and QLabel

    Is there a way to fix above program, build and run please?

    This book has many excellent Qt programming chapters. I like to be able to load the projects from this book into Qt Creator practice the Qt concepts please
    Thanks,
    Mike

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: C++ GUI Programming

    How did you install QtCreator, stand alone installer or from the Qt installation, or some other way ?
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. #3
    Join Date
    Jun 2017
    Posts
    19
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: C++ GUI Programming

    Installed using Qt installation. Thanks.


    Added after 7 minutes:


    I searched for QAapplication file on my Windows computer C drive and found following path for the QApplication include file:
    C:\Qt\5.9\mingw53_32\include\QtWidgets

    I am trying to add this folder path to the include path in Qt.
    How to add (menu, sub-menu selections?) this QtWidgets include path please?
    Last edited by Mike_m; 23rd June 2017 at 11:28.

  4. #4
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: C++ GUI Programming

    Can you show the "QT" variable assignments in project file i.e. the .pro file.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  5. #5
    Join Date
    Jun 2017
    Posts
    19
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: C++ GUI Programming

    I have hello.pro file and it has only following two lines:
    TEMPLATE = app
    SOURCES = hello.cpp

  6. #6
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: C++ GUI Programming

    Start new project in Qt Creator with wizard. Then look in the created PRO file.

  7. #7
    Join Date
    Jun 2017
    Posts
    19
    Thanks
    2
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: C++ GUI Programming

    I ran qmake command and now I have following lines in hello.pro
    TEMPLATE = app
    TARGET = hello
    INCLUDEPATH += .

    Can I manually add my QApplication path to above INCLUDEPATH line?

  8. #8
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: C++ GUI Programming

    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  9. #9
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: C++ GUI Programming

    I bought Prentice Hall Book, "C++ GUI Programming with Qt 4, Second Edition" by Blanchette and Summerfield. (2008 Published)
    Be aware that between Qt4 (for which this book was written) and Qt5 (which you are presumably using), the locations of Qt header files and almost the entire Qt source tree layout changed completely. In addition, there are some argument changes to some very basic classes and methods. So examples from Blanchette and Summerfield's book will probably not immediately compile from the downloaded source. The book is otherwise a great way to learn the basics of the C++ side Qt.

    Normally, you do not need to add explicit paths to Qt header files to the .pro file - when you "configure" the project with the correct "kit" in Qt Creator, it will set up the build environment to automatically find what it needs. The INCLUDEPATH directive in the .pro file is usually used for non-Qt headers, like those from external libraries.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Qt C++ CGI programming
    By karankumar1609 in forum General Programming
    Replies: 7
    Last Post: 4th October 2019, 12:56
  2. Is this a QT programming?
    By knuxie1135 in forum Newbie
    Replies: 1
    Last Post: 7th November 2012, 16:09
  3. QT programming on Mac os x
    By invictus in forum General Discussion
    Replies: 6
    Last Post: 5th June 2008, 18:34
  4. Qt programming
    By archanasubodh in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2008, 12:32
  5. QT COM Programming
    By sarav in forum Newbie
    Replies: 5
    Last Post: 24th February 2007, 13:41

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.