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. There was a strange error during compilation when including the Windows API header file before 'ui_mainwindow.h'.
Forum Updated to NodeBB v4.3 + New Features

There was a strange error during compilation when including the Windows API header file before 'ui_mainwindow.h'.

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.9k 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.
  • D Offline
    D Offline
    dfger
    wrote last edited by
    #1

    48871d30-b34c-4dd9-bbd8-7b8b170decf2-image.png
    dbeac10a-0a2c-49bb-85f9-2cb93a812841-image.png

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote last edited by
      #2

      Please provide a minimal, compilable example of your problem. I would guess you use a variable name which is also a define in the windows headers. Nothing Qt can do about it - use another name when you found out which one is causing the problem.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      D 1 Reply Last reply
      1
      • Christian EhrlicherC Christian Ehrlicher

        Please provide a minimal, compilable example of your problem. I would guess you use a variable name which is also a define in the windows headers. Nothing Qt can do about it - use another name when you found out which one is causing the problem.

        D Offline
        D Offline
        dfger
        wrote last edited by
        #3

        @Christian-Ehrlicher

        The reason has been identified, setting PushButton Icon to 'DocumentProperties' will trigger this issue.

        4ab1f50b-7d3d-4c5e-a596-9702b947247c-image.png

        JonBJ 1 Reply Last reply
        0
        • D dfger

          @Christian-Ehrlicher

          The reason has been identified, setting PushButton Icon to 'DocumentProperties' will trigger this issue.

          4ab1f50b-7d3d-4c5e-a596-9702b947247c-image.png

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote last edited by
          #4

          @dfger
          dwrite.h must be an MSVC header file, including definitions for its own DocumentProperties and it will have a line like

          #define DocumentProperties DocumentPropertiesW
          

          which MSVC uses for the "wide character" version. Meanwhile you are trying to use some Qt-defined symbol of DocumentProperties for the theme. And these clash.

          Try one of the following:

          • Move the #include <dwrite.h> line to after the #include ui_mainwindow.h. That may, or may not, be enough to make it work.

          • If you do not need the MSVC DocumentProperties define append line of #undef DocumentProperties immediately after the #include <dwrite.h>.

          • Move the #include <dwrite.h> line, and anything which uses its content, into another C++ source file of yours, where there is no UI stuff requiring the theme.

          D 1 Reply Last reply
          2
          • JonBJ JonB

            @dfger
            dwrite.h must be an MSVC header file, including definitions for its own DocumentProperties and it will have a line like

            #define DocumentProperties DocumentPropertiesW
            

            which MSVC uses for the "wide character" version. Meanwhile you are trying to use some Qt-defined symbol of DocumentProperties for the theme. And these clash.

            Try one of the following:

            • Move the #include <dwrite.h> line to after the #include ui_mainwindow.h. That may, or may not, be enough to make it work.

            • If you do not need the MSVC DocumentProperties define append line of #undef DocumentProperties immediately after the #include <dwrite.h>.

            • Move the #include <dwrite.h> line, and anything which uses its content, into another C++ source file of yours, where there is no UI stuff requiring the theme.

            D Offline
            D Offline
            dfger
            wrote last edited by
            #5

            @JonB Thank you for your suggestion. It is feasible for me to move it after "ui_mainwindow.h"

            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