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. QMouseEvent no such file or directory when header is included in another file
Forum Updated to NodeBB v4.3 + New Features

QMouseEvent no such file or directory when header is included in another file

Scheduled Pinned Locked Moved Solved General and Desktop
5 Posts 3 Posters 1.7k 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.
  • M Offline
    M Offline
    Mwoua
    wrote on 6 Jan 2017, 20:58 last edited by Mwoua 1 Jun 2017, 21:10
    #1

    Hello,
    I have a header StdAfx.h file with a lot of include. Among them, I have

    #include <QMouseEvent>
    #include <QPainter>
    #include <QSerialPort>

    And everything works fine. However, if I include this StdAfx.h into another header LtUtil.h that just defines several functions, I have several compilation error
    StdAfx.h:41: error: C1083: Cannot open include file: 'QMouseEvent': No such file or directory

    If I add QtGui/QMouseEvent it works and stop on the next include.

    Why do including my header prevents me from using the short #include <QMouseEvent> ?

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mrjj
      Lifetime Qt Champion
      wrote on 6 Jan 2017, 21:23 last edited by
      #2

      Hmm
      Maybe path are wrong when seen from StdAfx.h
      Is that not the normal visual studio common include?

      Also depends on the project settings, include paths etc.

      It should not prevent the use of
      #include <QMouseEvent>
      in any case.

      Are you using Qt4?

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Mwoua
        wrote on 6 Jan 2017, 21:39 last edited by Mwoua 1 Jun 2017, 21:45
        #3

        Im using qt 5.7.1 on Linux (Fedora) and Qt 5.7.0 on Windows 7 (same behavior)

        StdAfx is indeed usually something created by Visual Studio, but the person that created the code structure is long gone, so I dont really know why evertyhing is in a separate header and in a separate folder.

        edit : if I include StdAfx in my cpp instead of my header, everything is fine, so I guess I'll move the inlines function to the .cpp aswell.
        But I still dont understand why it messes up with Qt include

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on 6 Jan 2017, 21:58 last edited by Chris Kawa 1 Jun 2017, 21:59
          #4

          stdafx.h is usually intended to be a precompiled header, so it should be included as first thing in the .cpp files, not in headers.
          As to why your problem happens - this type of error usually means that the header you're including stdafx.h in or the file itself is not included in the project or is included in a project that doesn't use that Qt library (i.e. doesn't have that module in the .pro file or the include paths are not set correctly in the visual studio project, whichever you're using).

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Mwoua
            wrote on 6 Jan 2017, 22:04 last edited by
            #5

            Thanks for the clarification about the precompiled header.
            And I think your explanation about the issue correspond to my case.

            Now I need to think about how to include properly the header I need to declare my templates, but thats another story.

            1 Reply Last reply
            0

            1/5

            6 Jan 2017, 20:58

            • Login

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