3

First things first, yes I did do a thorough search of the dozens of like names posts and my solution was either not there or not apparent to my limited knowledge of the topic.

I am fairly proficient in C++, and use it often, but I have literally just discovered QT and decided to take a whack at it. The error is very basic, which I assume means I did something very basic incorrectly.

What I am using:

  1. Latest version of CodeBlocks
  2. Latest version of QT
  3. A piece of example code from this topic: (Display QImage with QtGui).
  4. Code blocks is installed here: C:\Program Files (x86)\CodeBlocks
  5. MinGW here: C:\MinGW\bin
  6. QT here: C:\Qt\4.8.5\bin

Here is my complete Environment path:

C:\Program Files (x86)\SSH Communications Security\SSH Secure Shell; C:\Qt\4.8.5\bin

From the post I referenced, it sounds like this is a complete and working program (I replaced the image with an image of my own), which further strengthens my opinion that I goofed in a small but profound way.

Referenced Code:

#include <QtGui/QApplication>
#include <QLabel>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QImage myImage;
    myImage.load("test.png");

    QLabel myLabel;
    myLabel.setPixmap(QPixmap::fromImage(myImage));

    myLabel.show();

    return a.exec();
}

The full error log from CodeBlocks build and run:

C:\Users\Josh\Dropbox\Code\Cards\qtTest_loadololo.cpp|1|fatal error: QtGui/QApplication: No such file or directory|
||===

 Build finished: 1 errors, 0 warnings (0 minutes, 4 seconds) ===|

The full build log:

\Dropbox\Code\Cards\qtTest_loadololo.o
C:\Users\Josh\Dropbox\Code\Cards\qtTest_loadololo.cpp:1:30: fatal error: QtGui/QApplication: No such file or directory
compilation terminated.
Process terminated with status 1 (0 minutes, 4 seconds)
1 errors, 0 warnings (0 minutes, 4 seconds)

Please do not assume anything I did not provide, I am extremely new to installing all of this and will not take offense to even the simplest of questions.

Community
  • 1
  • 1
Joshua
  • 4,270
  • 10
  • 42
  • 62
  • Can you paste also the *complete* compiler's command line? – peppe Jul 09 '13 at 20:14
  • @peppe Edit: I might have found it. – Joshua Jul 09 '13 at 20:20
  • 4
    Erk... how about using Qt Creator instead? :-) Anyhow, are you at least using qmake for managing the build? Can you try opening a Qt shell -- you should have a link in your Start menu --, walk into your application's dir, and run 1) qmake 2) mingw32-make ? – peppe Jul 09 '13 at 20:22
  • I'll try that, one moment. Simply qmake, or qmake ? – Joshua Jul 09 '13 at 20:23
  • Upvote for QtCreator suggestion - at least until you can get comfortable with the moc'ing system (auto-gen/code) – Son-Huy Pham Jul 09 '13 at 20:25
  • I did qmake and it just gives a ton of options, I then did mingw32-make and it simply stated that I did not have a makefile. I'll looka t QT Creator – Joshua Jul 09 '13 at 20:29
  • It just means you don't have a .pro file. It's likely that the build is failing because you need to tell CodeBlocks where the Qt includes+libs are, how to properly `moc` files, etc. (Or, how to manage a qmake project). I don't know enough of CodeBlocks to help you with that, but again, give Qt Creator a try. :-) – peppe Jul 09 '13 at 20:41
  • @peppe Thanks a ton, very helpful in any case – Joshua Jul 09 '13 at 20:59
  • The answer supplied by Jassim in this post: [Error QApplication: no such file or directory](http://stackoverflow.com/questions/8995399/error-qapplication-no-such-file-or-directory) helped me to solve this same issue on Qt5.0+, replacing #include with: #include – Jadent Nov 22 '13 at 22:02

2 Answers2

5

I had the same problem on Fedora Linux. I have solved it changing the import line to

#include <QApplication>

and instead of using qmake (which uses QT3) it had to use qmake-qt4 (for QT4).

erik
  • 2,278
  • 1
  • 23
  • 30
0

I had a similar issue when upgrading from Qt4 to Qt5. I know your path says Qt 4.8.5, but maybe you have multiple versions installed. Your post is dated 2013-07-09, and Qt 5.0 was released at 2012-12-09.

Try to take a look at http://qt-project.org/wiki/Transition_from_Qt_4.x_to_Qt5 - maybe it will help you. It did help me.

Peer Sommerlund
  • 502
  • 6
  • 14