error: C1083: Cannot open include file: 'QMainWindow': No such file or directory
-
I tried to make my first application qith Qt, Creator, Qt Widgets Application, I didn't add anythin, only the code that Qt automatically produces exist in the project.
But it gives this error when I run it: error: C1083: Cannot open include file: 'QMainWindow': No such file or directory.
How can I fix this?It's Win 7, Qt Creator 4.2.1.
-
It sounds like your kit isn't set up properly.
It's in the settings somewhere I don't have access to Qt Creator right now to check, but there is a place to configure your kits. Make sure it points to your Qt kit you want to use i.e. 5.8.
Then the build should work properly. If someone with more Creator knowledge comes by fill free to give more detailed info. :)
-
Hi,
Also check that your .pro file contains
QT += widgets
. -
Did you install a custom MinGW version rather that the on proposed with Qt ?
-
It does contain 'QT += widgets'.
I put in the PATH Env. Variable: C:\mingw32\bin and worked!!!@Panoss said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
It does contain 'QT += widgets'.
I put in the PATH Env. Variable: C:\mingw32\bin and worked!!!Be careful with custom mingw's like that. Qt does not work with a lot of mingw versions. I find most builds target a specific mingw and going outside that specific one leads to compilation issues and problems.
Not saying it will happen but it's definitely something to be careful of.
The proper fix is to make sure your Qt Creator can see your kit, i.e. the mingw that Qt installed, in it's settings.
Either way though, glad it's working. :) Just know if you start having weird problems, you may need to look at compiler.
-
@Panoss said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
It does contain 'QT += widgets'.
I put in the PATH Env. Variable: C:\mingw32\bin and worked!!!Be careful with custom mingw's like that. Qt does not work with a lot of mingw versions. I find most builds target a specific mingw and going outside that specific one leads to compilation issues and problems.
Not saying it will happen but it's definitely something to be careful of.
The proper fix is to make sure your Qt Creator can see your kit, i.e. the mingw that Qt installed, in it's settings.
Either way though, glad it's working. :) Just know if you start having weird problems, you may need to look at compiler.
@ambershark said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
The proper fix is to make sure your Qt Creator can see your kit, i.e. the mingw that Qt installed, in it's settings.
I think you 're right, and this is what I want, the proper fix, not just a fix.
But you know, I was struggling for hours to make Qt Creator work, and when I finally made it work, I was soo excited!How can I make it work with the proper settings? (compiler etc..)
Has Qt Creator a MingW in it's folders?
Why doesn't it find it automatically?@SGaist said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
Did you install a custom MinGW version rather that the on proposed with Qt ?
The mingw I installed in C:\mingw32, is irrelevant to Qt Creator. (which mingw version is proposed for Qt? Is it the mingw-builds i686-4.8.2-release-posix-dwarf-rt_v3-rev3 according to this? If this is the one, then I 'm very lucky!! This is the mingw version installed in C:\mingw32!!)
I had it installed before I installed Qt Creator and I used it with NetBeans.Here is the list of the compilers, the first in the list is the one that was added after I modified the PATH variable (as I mentioned above)
And the list of kits:
-
@ambershark said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
The proper fix is to make sure your Qt Creator can see your kit, i.e. the mingw that Qt installed, in it's settings.
I think you 're right, and this is what I want, the proper fix, not just a fix.
But you know, I was struggling for hours to make Qt Creator work, and when I finally made it work, I was soo excited!How can I make it work with the proper settings? (compiler etc..)
Has Qt Creator a MingW in it's folders?
Why doesn't it find it automatically?@SGaist said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
Did you install a custom MinGW version rather that the on proposed with Qt ?
The mingw I installed in C:\mingw32, is irrelevant to Qt Creator. (which mingw version is proposed for Qt? Is it the mingw-builds i686-4.8.2-release-posix-dwarf-rt_v3-rev3 according to this? If this is the one, then I 'm very lucky!! This is the mingw version installed in C:\mingw32!!)
I had it installed before I installed Qt Creator and I used it with NetBeans.Here is the list of the compilers, the first in the list is the one that was added after I modified the PATH variable (as I mentioned above)
And the list of kits:
@Panoss From the picture you posted I can see that Qt creator recognized MinGW.
The second picture shows that you have issues with two of your Kits: Desctop and Unnamed.
You should check them. Which of these Kits are you using?
It is better to use MinGW which is provided with Qt: just use Qt Maintenance Tool to install Qt for MinGW and MinGW. I never had any issues with this combination. -
@Panoss From the picture you posted I can see that Qt creator recognized MinGW.
The second picture shows that you have issues with two of your Kits: Desctop and Unnamed.
You should check them. Which of these Kits are you using?
It is better to use MinGW which is provided with Qt: just use Qt Maintenance Tool to install Qt for MinGW and MinGW. I never had any issues with this combination. -
@jsulm said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
just use Qt Maintenance Tool to install Qt...
What is Qt Maintenance tool?
-
I 'm currently installing it with the online installer.
It says it needs 6,32 (!!!)GB space for installation!
Now I remembered why I had rejected Qt Designer and tried to use NetBeans.
Anyway, I will install it for now, but later I will try the other way which is much more 'economical' when we 're talking about HDD space. -
I 'm currently installing it with the online installer.
It says it needs 6,32 (!!!)GB space for installation!
Now I remembered why I had rejected Qt Designer and tried to use NetBeans.
Anyway, I will install it for now, but later I will try the other way which is much more 'economical' when we 're talking about HDD space.@Panoss 6,32GB?! What did you select to install? QtCreator is around 240MB, I don't think Netbeans is smaller. Qt 5.8 consumes 2,87GB on my machine.
Which of the Kits did you use? All auto-detected Kits are for Visual Studio, not MinGW! It looks like you installed several Qt versions for Visual Studio, why? You wanted to use MinGW, right?
Remove all Qt for Visual Studio and add Qt 5.8 for MinGW and make sure MinGW is selected under Qt/Tools in Qt Maintenance Tool. -
@Panoss 6,32GB?! What did you select to install? QtCreator is around 240MB, I don't think Netbeans is smaller. Qt 5.8 consumes 2,87GB on my machine.
Which of the Kits did you use? All auto-detected Kits are for Visual Studio, not MinGW! It looks like you installed several Qt versions for Visual Studio, why? You wanted to use MinGW, right?
Remove all Qt for Visual Studio and add Qt 5.8 for MinGW and make sure MinGW is selected under Qt/Tools in Qt Maintenance Tool.@jsulm said in error: C1083: Cannot open include file: 'QMainWindow': No such file or directory:
@Panoss 6,32GB?! What did you select to install? QtCreator is around 240MB, I don't think Netbeans is smaller. Qt 5.8 consumes 2,87GB on my machine.
I left the default settings.
Indeed, I saw multiple versions of Qt selected, but I thought 'it's the default, I'll leave it as is'Which of the Kits did you use? All auto-detected Kits are for Visual Studio, not MinGW! It looks like you installed several Qt versions for Visual Studio, why?
No, I didn't want anything ike this. They automatically got installed. I 'll remove them.
You wanted to use MinGW, right?
Yeah. It's just that I 'm an absolute beginner and I've messed everything up!
Remove all Qt for Visual Studio and add Qt 5.8 for MinGW
I 'll do this.
and make sure MinGW is selected under Qt/Tools in Qt Maintenance Tool.
This is what I had selected in the beginning, but then I deselected MinGW under Qt/Tools and selected MinGW under Qt 5.8.
And worked, while with the previous selection didn't.
(I noticed that when I selected the MinGW under Qt 5.8, automatically a MinGW under Qt/Tools was also selected ) -
jsulm I did as you said, I made a test Qt Applicaion, it run from the very first time!!
But, in the editor, it shows errors: words underlined with red color, others with yellow - light green color.
And red circles on the left.
But, despite these, the program compiles and runs!
Take a look at the picture to see what I mean:
EDIT: The errors disappeared! I didn't do anything!
-
Might be the code model that wasn't completely initialised yet.
-
By the way, since you have it working now, please mark the thread as solved using the "Topic Tools" button so that other forum members may know a solution has been found :)