Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Qt 6
  4. warning: implicit conversion turns string literal into bool: 'const char [11]' to 'bool' qobjectdefs.h:61:42: note: expanded from macro 'Q_PROPERTY'
QtWS25 Last Chance

warning: implicit conversion turns string literal into bool: 'const char [11]' to 'bool' qobjectdefs.h:61:42: note: expanded from macro 'Q_PROPERTY'

Scheduled Pinned Locked Moved Unsolved Qt 6
5 Posts 4 Posters 1.3k 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.
  • E Offline
    E Offline
    Erdem Badluev
    wrote on last edited by
    #1

    i have this warning, after update to Qt 6.0:

    #ifndef COORD_2D_H
    #define COORD_2D_H
    
    #include <QObject>
    
    class coord_2d : public QObject
    {
        Q_OBJECT
        Q_PROPERTY(qreal x READ x WRITE setX)  // <-- here
        Q_PROPERTY(qreal y READ y WRITE setY)  // <-- here
    public:
        explicit coord_2d(QObject *parent = nullptr);
    
        void setX(qreal);
        qreal x();
        void setY(qreal);
        qreal y();
    
    private:
        qreal mX,mY;
    
    signals:
    
    };
    
    #endif // COORD_2D_H
    
    

    what's wrong? on Qt 5.12 it worked.

    1 Reply Last reply
    1
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Which OS are you running ?
      Which compiler are you using ?
      Can you show your .pro file ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Benoit Thouy
        wrote on last edited by Benoit Thouy
        #3

        I have the exact same problem after updating Qt 5.12.2. I am working with mingw 7.3_64 (win10). I don't have changed anything in my .pro between

        Every property raises the warning, either in class with Q_OBJECT or with Q_GADGET.
        In the warning tooltip, the expansion of the macro seems to be now:

        #define Q_PROPERTY(arg...) static_assert("Q_PROPERTY", #arg);
        

        Which does not look good for defining property correctly.

        Edit The include files does not seem to be coherent. If I follow the symbol, I get the right macro in file C:\Qt\Qt5.12.2\5.12.2\mingw73_64\include\QtCore\qobjectdefs.h. If I follow th the tooltip, I fall into C:\Qt\Qt5.12.2\Tools\QtCreator\share\qtcreator\cplusplus\wrappedQtHeaders\QtCore\qobjectdefs.h

        1 Reply Last reply
        1
        • B Offline
          B Offline
          Benoit Thouy
          wrote on last edited by
          #4

          Ok, after searching for a solution, it seems that it is linked with the update of QtCreator from 4.9 to 4.14. I have uninstalled everything and install from scratch version 5.12.3. Everything compiles fine, no warning. Then I launch MaintenanceTool and update to 4.14, and the warnings appear, compilation failed as the properties are not well defined.
          This is not a solution. We are stuck with QtCreator 4.9, but big problems arise if we want to use external components (MaintenanceTool requests the update).

          P 1 Reply Last reply
          1
          • B Benoit Thouy

            Ok, after searching for a solution, it seems that it is linked with the update of QtCreator from 4.9 to 4.14. I have uninstalled everything and install from scratch version 5.12.3. Everything compiles fine, no warning. Then I launch MaintenanceTool and update to 4.14, and the warnings appear, compilation failed as the properties are not well defined.
            This is not a solution. We are stuck with QtCreator 4.9, but big problems arise if we want to use external components (MaintenanceTool requests the update).

            P Offline
            P Offline
            pogojotz
            wrote on last edited by
            #5

            @Benoit-Thouy Please elaborate "compilation failed as the properties are not well defined"
            The warning is issued by the Clang Code Model and can be squelched by creating a new Diagnostic Configuration (or use your existing one) in Options...->C++->Code Model->Diagnostic Configuration and adding "-Wno-string-conversion" to it.

            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