Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Qt Creator Clang Code Model - Q_DECLARE_OPERATORS_FOR_FLAGS
Forum Updated to NodeBB v4.3 + New Features

Qt Creator Clang Code Model - Q_DECLARE_OPERATORS_FOR_FLAGS

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
4 Posts 2 Posters 476 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.
  • P Offline
    P Offline
    poucz
    wrote on last edited by
    #1

    Hello,
    in QtCreator I have these piece of test code:

    class MyClass
    {
    public:
        enum Option {
            NoOptions = 0x0,
            ShowTabs = 0x1,
            ShowAll = 0x2,
            SqueezeBlank = 0x4
        };
        Q_DECLARE_FLAGS(Options, Option)
    };
    
    Q_DECLARE_OPERATORS_FOR_FLAGS(MyClass::Options)
    

    Clang Code model mark this line red with error:
    screen.png

    What I make wrong?

    I look at "qnamespace.h" there are lot of Q_DECLARE_OPERATORS_FOR_FLAGS without showing error.

    file_logger.h:20:1: error: invalid operands to binary expression ('QFlags<MyClass::Options::enum_type>' (aka 'QFlags<MyClass::Option>') and 'MyClass::Options::enum_type' (aka 'MyClass::Option'))
    qflags.h:180:39: note: expanded from macro 'Q_DECLARE_OPERATORS_FOR_FLAGS'
    file_logger.h:20:1: note: candidate function not viable: no known conversion from 'QFlags<MyClass::Options::enum_type>' (aka 'QFlags<MyClass::Option>') to 'MyClass::Options::enum_type' (aka 'MyClass::Option') for 1st argument
    qflags.h:179:50: note: expanded from macro 'Q_DECLARE_OPERATORS_FOR_FLAGS'
    qnamespace.h:1770:1: note: candidate function not viable: no known conversion from 'QFlags<MyClass::Options::enum_type>' (aka 'QFlags<MyClass::Option>') to 'Qt::MouseButtons::enum_type' (aka 'Qt::MouseButton') for 1st argument
    qflags.h:182:21: note: expanded from macro 'Q_DECLARE_OPERATORS_FOR_FLAGS'
    qflags.h:175:43: note: expanded from macro 'Q_DECLARE_INCOMPATIBLE_FLAGS'
    qnamespace.h:1771:1: note: candidate function not viable: no known conversion from 'QFlags<MyClass::Options::enum_type>' (aka 'QFlags<MyClass::Option>') to 'Qt::Orientations::enum_type' (aka 'Qt::Orientation') for 1st argument
    ...
    qflags.h:179:50: note: expanded from macro 'Q_DECLARE_OPERATORS_FOR_FLAGS'
    qfiledevice.h:150:1: note: candidate function not viable: no known conversion from 'QFlags<MyClass::Options::enum_type>' (aka 'QFlags<MyClass::Option>') to 'QFileDevice::Permissions::enum_type' (aka 'QFileDevice::Permission') for 1st argument
    qflags.h:181:50: note: expanded from macro 'Q_DECLARE_OPERATORS_FOR_FLAGS
    

    Thanks

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      Hi
      I tried on window 10 / Qt5.15 visual stud compiler and
      it didn't complain.

      What os/ Qt version and compiler are you seeing this with ?

      alt text

      1 Reply Last reply
      0
      • P Offline
        P Offline
        poucz
        wrote on last edited by
        #3

        Thank you for reply.

        Solved by changing toolchain.

        I'm using:
        Qt Creator 4.14.1
        Base on Qt 5.15.2 (GCC 7.3.1 20180303 (Red Hat 7.3.1-5), 64 bit)
        ClangCodeModel: 4.14.1 (4.14.0)

        Error appear with QT5.10 toolchain (gcc 4.8)
        When I use QT5.15 error disapear. (gcc 8.3.0)

        mrjjM 1 Reply Last reply
        1
        • P poucz

          Thank you for reply.

          Solved by changing toolchain.

          I'm using:
          Qt Creator 4.14.1
          Base on Qt 5.15.2 (GCC 7.3.1 20180303 (Red Hat 7.3.1-5), 64 bit)
          ClangCodeModel: 4.14.1 (4.14.0)

          Error appear with QT5.10 toolchain (gcc 4.8)
          When I use QT5.15 error disapear. (gcc 8.3.0)

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @poucz

          a bit of googling around suggested that there was some bug in Qt about
          Q_DECLARE_OPERATORS_FOR_FLAGS that was fixed in 5.12
          so that makes sense if you had it in 5.10 and then gone in 5.15.

          1 Reply Last reply
          1

          • Login

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