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. Enum issue in VC2012 and MinGW
Forum Updated to NodeBB v4.3 + New Features

Enum issue in VC2012 and MinGW

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.0k Views 1 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.
  • U Offline
    U Offline
    user001
    wrote on 6 Mar 2014, 18:11 last edited by
    #1

    I just switched from VC2012 and MinGW, http://qt-project.org/forums/viewthread/39285/. I just found the issue is not switch the project itself. It is the enum issue. The enum is treated differently in VC2012 edition and MinGW edition!

    In VC2012 edition, we refer an enum value like this: MyEnum status = MyEnum::Value1;.
    But in MinGW edition, it only take this format: MyEnum status = Value1;.

    For example this following line works in VC2012:

    mainWindow->addToolBar(Qt::ToolBarArea::LeftToolBarArea, taskToolBar);

    But it doesn't work in MinGW now.

    How to avoid this confliction?

    Is the C++11 supported by Qt MinGW 5.2.1 by default? or I need to do some configuration?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      hskoglund
      wrote on 6 Mar 2014, 19:06 last edited by
      #2

      Yeah, you need to add this line to your .pro file:
      @CONFIG += c++11@

      (Because MinGW defaults to old C++ and VC2012 defaults to C++11)

      P.S. The enum is treated differently not because of different compilers, but depending on if you compile for C++11 or not.

      BTW: If you don't want these kind of surprises, you can code so that it compiles ok, regardless of C++11 switched on or not, by not scoping your enums, i.e. like this instead:
      mainWindow->addToolBar(Qt::LeftToolBarArea, taskToolBar);

      1 Reply Last reply
      0

      1/2

      6 Mar 2014, 18:11

      • Login

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