Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. error: C1083: Cannot open include file: 'QMainWindow': No such file or directory
QtWS25 Last Chance

error: C1083: Cannot open include file: 'QMainWindow': No such file or directory

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 4 Posters 14.2k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Panoss
    wrote on last edited by
    #1

    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.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ambershark
      wrote on last edited by
      #2

      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. :)

      My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        Also check that your .pro file contains QT += widgets.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0
        • P Offline
          P Offline
          Panoss
          wrote on last edited by
          #4

          It does contain 'QT += widgets'.
          I put in the PATH Env. Variable: C:\mingw32\bin and worked!!!

          A 1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            Did you install a custom MinGW version rather that the on proposed with Qt ?

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • P Panoss

              It does contain 'QT += widgets'.
              I put in the PATH Env. Variable: C:\mingw32\bin and worked!!!

              A Offline
              A Offline
              ambershark
              wrote on last edited by
              #6

              @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.

              My L-GPL'd C++ Logger github.com/ambershark-mike/sharklog

              P 1 Reply Last reply
              0
              • A ambershark

                @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.

                P Offline
                P Offline
                Panoss
                wrote on last edited by Panoss
                #7

                @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)
                alt text

                And the list of kits:
                alt text

                jsulmJ 1 Reply Last reply
                0
                • P Panoss

                  @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)
                  alt text

                  And the list of kits:
                  alt text

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  P 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @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.

                    P Offline
                    P Offline
                    Panoss
                    wrote on last edited by Panoss
                    #9

                    @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?

                    jsulmJ 1 Reply Last reply
                    0
                    • P Panoss

                      @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?

                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Panoss If you used Qt Online Installer to install Qt then you have a tool in your Qt installation directory - Qt Maintenance Tool. You can use to update your installation, install other Qt versions and MinGW.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0
                      • P Offline
                        P Offline
                        Panoss
                        wrote on last edited by
                        #11

                        I didn't use the Online installer.
                        I will uninstall my current Qt Creator and use the Online installer.

                        1 Reply Last reply
                        0
                        • P Offline
                          P Offline
                          Panoss
                          wrote on last edited by Panoss
                          #12

                          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.

                          jsulmJ 1 Reply Last reply
                          0
                          • P Offline
                            P Offline
                            Panoss
                            wrote on last edited by
                            #13

                            It finished the installation and I tried to make a Qt Application to test it.
                            But, no:
                            The program has unexpectedly finished.

                            I looked at kits:
                            alt text

                            1 Reply Last reply
                            0
                            • P Panoss

                              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.

                              jsulmJ Offline
                              jsulmJ Offline
                              jsulm
                              Lifetime Qt Champion
                              wrote on last edited by jsulm
                              #14

                              @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.

                              https://forum.qt.io/topic/113070/qt-code-of-conduct

                              P 1 Reply Last reply
                              1
                              • jsulmJ jsulm

                                @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.

                                P Offline
                                P Offline
                                Panoss
                                wrote on last edited by Panoss
                                #15

                                @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 )

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  Panoss
                                  wrote on last edited by Panoss
                                  #16

                                  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:
                                  alt text

                                  EDIT: The errors disappeared! I didn't do anything!

                                  1 Reply Last reply
                                  0
                                  • SGaistS Offline
                                    SGaistS Offline
                                    SGaist
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #17

                                    Might be the code model that wasn't completely initialised yet.

                                    Interested in AI ? www.idiap.ch
                                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    1 Reply Last reply
                                    1
                                    • SGaistS Offline
                                      SGaistS Offline
                                      SGaist
                                      Lifetime Qt Champion
                                      wrote on last edited by
                                      #18

                                      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 :)

                                      Interested in AI ? www.idiap.ch
                                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                      1 Reply Last reply
                                      0

                                      • Login

                                      • Login or register to search.
                                      • First post
                                        Last post
                                      0
                                      • Categories
                                      • Recent
                                      • Tags
                                      • Popular
                                      • Users
                                      • Groups
                                      • Search
                                      • Get Qt Extensions
                                      • Unsolved