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. Cannot open include file error
Forum Updated to NodeBB v4.3 + New Features

Cannot open include file error

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 3.0k Views 2 Watching
  • 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.
  • K Offline
    K Offline
    KunLin
    wrote on last edited by KunLin
    #1

    Hi

    I'm a new Qt user and I've encountered a problem of using custom widget. Here is the description. Can anyone please help me out?

    I'm using VS2013 with Qt5 Addin.

    I created a MyOpenGLWidget inherits QOpenGLWidget in a DLL called UiWidgets that I created. The uic and moc and compilation worked fine.

    Then I want to use this widget in my other project MyApp. I designed the interface in QtDesigner and added the MyOpenGLWidget. I promoted the QOpenGLWidget in QtDesigner to MyOpenGLWidget and set the header file to "../UiWIdgets/MyOpenGLWidget.h" (Since both the projects exists under the same solution directory, it should work)

    But, after I coded the MyApp class and try to compile it, I got the following error.

    1> Uic'ing MyApp.ui...
    1> MyApp.cpp
    1>c:\dev\projects\MyProject\MyApp\../UiWidgets/MyOpenGLWidget.h(18): fatal error C1083: Cannot open include file: 'ui_MyOpenGLWidget.h': No such file or directory
    1> moc_MyApp.cpp
    1>c:\dev\projects\MyProject\MyApp\../UiWidgets/MyOpenGLWidget.h(18): fatal error C1083: Cannot open include file: 'ui_MyOpenGLWidget.h': No such file or directory
    1> main.cpp
    1>c:\dev\projects\MyProject\MyApp\../UiWidgets/MyOpenGLWidget.h(18): fatal error C1083: Cannot open include file: 'ui_MyOpenGLWidget.h': No such file or directory
    1> Generating Code...
    

    My question is:

    • The path is fine (I checked in the command line). Why is the error, did I miss somethin important?
    • Is there a better practice to do so?
    1 Reply Last reply
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      Hi and welcome to devnet

      Does file "ui_MyOpenGLWidget.h" exist and where?

      It looks to me like you have a path issue and "ui_MyOpenGLWidget.h" is somewhere located, but not in a folder of the path.

      Vote the answer(s) that helped you to solve your issue(s)

      K 1 Reply Last reply
      0
      • K koahnig

        Hi and welcome to devnet

        Does file "ui_MyOpenGLWidget.h" exist and where?

        It looks to me like you have a path issue and "ui_MyOpenGLWidget.h" is somewhere located, but not in a folder of the path.

        K Offline
        K Offline
        KunLin
        wrote on last edited by
        #3

        @koahnig Thank you for replying. The file is located at ProjectDir/GeneratedFiles/ui_MyOpenGLWidget.h. I wonder wouldn't it be enough to specify the path of only MyOpenGLWidget.h other than ui_MyOpenGLWidget.h? Since ui_XXX.h is generated by uic?

        K 1 Reply Last reply
        0
        • K KunLin

          @koahnig Thank you for replying. The file is located at ProjectDir/GeneratedFiles/ui_MyOpenGLWidget.h. I wonder wouldn't it be enough to specify the path of only MyOpenGLWidget.h other than ui_MyOpenGLWidget.h? Since ui_XXX.h is generated by uic?

          K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          @KunLin

          If you have only one projectdir I am agreeing, but I understood that you may have two.
          When you setup a dll project all will be consistent within this project for compilation and linking. Typically the ui_*.h files are generated in a build folder. However, your project setup will know about it.
          If you try to use the same header in another project (in your case MyOpenGLWidget.h), but the associated ui-file (in your case ui_MyOpenGLWidget.h) is not in the same folder, your project setup cannot know.

          Vote the answer(s) that helped you to solve your issue(s)

          K 1 Reply Last reply
          0
          • K koahnig

            @KunLin

            If you have only one projectdir I am agreeing, but I understood that you may have two.
            When you setup a dll project all will be consistent within this project for compilation and linking. Typically the ui_*.h files are generated in a build folder. However, your project setup will know about it.
            If you try to use the same header in another project (in your case MyOpenGLWidget.h), but the associated ui-file (in your case ui_MyOpenGLWidget.h) is not in the same folder, your project setup cannot know.

            K Offline
            K Offline
            KunLin
            wrote on last edited by KunLin
            #5

            @koahnig

            Thank you. That makes sense. So do you have any advice about how to use a custom widget in DLL? And after I modified this include in MyOpenGLWidget.h

            #include "ui_MyOpenGLWidget.h"
            

            to

            #include "GeneratedFiles/ui_MyOpenGLWidget.h"
            

            and it complies and runs like charm. And indeed I added ".\GeneratedFiles" in my additional include directories.

            But I still do not know the reason.

            1 Reply Last reply
            0
            • K Offline
              K Offline
              koahnig
              wrote on last edited by
              #6

              I am not using setups similar to yours. Therefore my advise might be wrong.

              Anyway, I assume you have a dll project with follwoing structure:

              • dllProject with MyOpenGLWidget.h
              • dllProject/GeneratedFiles with ui_MyOpenGLWidget.h

              and

              • ProjectDir with your new project files
              • ProjectDir/GeneratedFiles with some generated files for the new project

              Since ProjectDir is your current project directory ./GeneratedFiles will point to ProjectDir/GeneratedFiles

              Your INCLUDEPATH will hold at least dllProject ProjectDir/GeneratedFiles
              you probably should add dllProject/GeneratedFiles
              and you should be fine.

              One note: You seem to use the backward slash '\' as it is tradition under windows. However, nowadays windows does also accept a foward slash '/'. I would recomment to use in general the linux compatible '/' also for any folder handling within Qt related files. Sometimes this may help you to prevent severe difficulties.

              Vote the answer(s) that helped you to solve your issue(s)

              K 1 Reply Last reply
              1
              • K koahnig

                I am not using setups similar to yours. Therefore my advise might be wrong.

                Anyway, I assume you have a dll project with follwoing structure:

                • dllProject with MyOpenGLWidget.h
                • dllProject/GeneratedFiles with ui_MyOpenGLWidget.h

                and

                • ProjectDir with your new project files
                • ProjectDir/GeneratedFiles with some generated files for the new project

                Since ProjectDir is your current project directory ./GeneratedFiles will point to ProjectDir/GeneratedFiles

                Your INCLUDEPATH will hold at least dllProject ProjectDir/GeneratedFiles
                you probably should add dllProject/GeneratedFiles
                and you should be fine.

                One note: You seem to use the backward slash '\' as it is tradition under windows. However, nowadays windows does also accept a foward slash '/'. I would recomment to use in general the linux compatible '/' also for any folder handling within Qt related files. Sometimes this may help you to prevent severe difficulties.

                K Offline
                K Offline
                KunLin
                wrote on last edited by
                #7
                This post is deleted!
                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