Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Special Interest Groups
  3. C++ Gurus
  4. error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'

error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'

Scheduled Pinned Locked Moved Solved C++ Gurus
19 Posts 7 Posters 2.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.
  • A Offline
    A Offline
    Alcor
    wrote on 17 Jul 2023, 15:07 last edited by
    #1

    Hi Everybody, This is my first post on this forum. Forgive me if it's a repeat post. I am using Qt6.5 with Visual Studio 2022. I am trying to build an old piece of code in Qt Creator. There is no issue with any source file of the code. But I am getting this error.
    "error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'"

    Full details.

    C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\type_traits:334: error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'
    C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\type_traits(334): error C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'
    C:\Qt\6.5.1\msvc2019_64\include\QtCore/qstringview.h(22): note: see declaration of 'QString'
    C:\Qt\6.5.1\msvc2019_64\include\QtCore/qanystringview.h(82): note: see reference to class template instantiation 'std::is_convertible<QStringTokenizerBaseBase::tokenizer_state &,QString>' being compiled
    C:\Qt\6.5.1\msvc2019_64\include\QtCore/qanystringview.h(82): note: see reference to variable template 'const bool conjunction_v<std::negation<std::disjunction<std::is_same<QStringTokenizerBaseBase::tokenizer_state,enum QAnyStringView::Tag>,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QAnyStringView,std::is_pointerQStringTokenizerBaseBase::tokenizer_state,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QByteArray,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QString > >,std::is_convertible<QStringTokenizerBaseBase::tokenizer_state &,QString> >' being compiled
    C:\Qt\6.5.1\msvc2019_64\include\QtCore/qanystringview.h(216): note: see reference to alias template instantiation 'QAnyStringView::if_convertible_to<QString,QStringTokenizerBaseBase::tokenizer_state&>' being compiled

    I have also attached the screenshot of the Qt Creator Screen. Please help me as I have no clue about it.

    Screenshot 2023-07-17 104102.jpg

    J 1 Reply Last reply 17 Jul 2023, 15:20
    0
    • W Offline
      W Offline
      WWebber
      wrote 17 days ago last edited by
      #19

      Found it!
      This error was caused by the compiler option "/Zc:hiddenFriend-" !

      1 Reply Last reply
      2
      • A Alcor
        17 Jul 2023, 15:07

        Hi Everybody, This is my first post on this forum. Forgive me if it's a repeat post. I am using Qt6.5 with Visual Studio 2022. I am trying to build an old piece of code in Qt Creator. There is no issue with any source file of the code. But I am getting this error.
        "error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'"

        Full details.

        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\type_traits:334: error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'
        C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Tools\MSVC\14.36.32532\include\type_traits(334): error C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'
        C:\Qt\6.5.1\msvc2019_64\include\QtCore/qstringview.h(22): note: see declaration of 'QString'
        C:\Qt\6.5.1\msvc2019_64\include\QtCore/qanystringview.h(82): note: see reference to class template instantiation 'std::is_convertible<QStringTokenizerBaseBase::tokenizer_state &,QString>' being compiled
        C:\Qt\6.5.1\msvc2019_64\include\QtCore/qanystringview.h(82): note: see reference to variable template 'const bool conjunction_v<std::negation<std::disjunction<std::is_same<QStringTokenizerBaseBase::tokenizer_state,enum QAnyStringView::Tag>,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QAnyStringView,std::is_pointerQStringTokenizerBaseBase::tokenizer_state,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QByteArray,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QString > >,std::is_convertible<QStringTokenizerBaseBase::tokenizer_state &,QString> >' being compiled
        C:\Qt\6.5.1\msvc2019_64\include\QtCore/qanystringview.h(216): note: see reference to alias template instantiation 'QAnyStringView::if_convertible_to<QString,QStringTokenizerBaseBase::tokenizer_state&>' being compiled

        I have also attached the screenshot of the Qt Creator Screen. Please help me as I have no clue about it.

        Screenshot 2023-07-17 104102.jpg

        J Offline
        J Offline
        JonB
        wrote on 17 Jul 2023, 15:20 last edited by
        #2

        @Alcor
        In your original code, prior to whatever line causes the error, do you have something like #include <QString> or equivalent other #include which will lead to this?

        A 1 Reply Last reply 17 Jul 2023, 15:31
        0
        • J JonB
          17 Jul 2023, 15:20

          @Alcor
          In your original code, prior to whatever line causes the error, do you have something like #include <QString> or equivalent other #include which will lead to this?

          A Offline
          A Offline
          Alcor
          wrote on 17 Jul 2023, 15:31 last edited by
          #3

          @JonB

          "In your original code, prior to whatever line causes the error, do you have something like...."

          How do I find which line in which file of my code is causing this error?

          S K 2 Replies Last reply 17 Jul 2023, 17:21
          0
          • A Alcor
            17 Jul 2023, 15:31

            @JonB

            "In your original code, prior to whatever line causes the error, do you have something like...."

            How do I find which line in which file of my code is causing this error?

            S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 17 Jul 2023, 17:21 last edited by
            #4

            @Alcor hi and welcome to devnet,

            Where in your code is QString used ?
            Do all the files that do something with it contain the proper include ?

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

            A 1 Reply Last reply 17 Jul 2023, 18:52
            0
            • S SGaist
              17 Jul 2023, 17:21

              @Alcor hi and welcome to devnet,

              Where in your code is QString used ?
              Do all the files that do something with it contain the proper include ?

              A Offline
              A Offline
              Alcor
              wrote on 17 Jul 2023, 18:52 last edited by
              #5

              @SGaist

              There are many source code files that are using QString such as those given below. But none of these files have directive #include<QString>. I thought adding the line #include<QString> will make the error go away but it unfortunately it stays.

              "
              foreach(const QString &preset, presets)
              {
              QStringList temp = preset.split(";");
              m_ui->presetComboBox->addItem(temp[0], temp[1] + ":" + temp[2]);
              }

              "

              or
              "
              void DateTimeWidget::on_utcOffsetDoubleSpinBox_valueChanged(double d)
              {
              QString prefix("UTC");
              if(d >= 0.0)
              prefix.append("+");

              m_ui->utcOffsetDoubleSpinBox->setPrefix(prefix);
                 
              autoApply();
              

              }

              "

              or
              "
              void CollapsibleDockWidget::updateWindowTitle(QString windowTitle)
              {
              if(_titleBar)
              _titleBar->setWindowTitle(windowTitle);
              }

              "

              S 1 Reply Last reply 17 Jul 2023, 19:43
              0
              • A Alcor
                17 Jul 2023, 18:52

                @SGaist

                There are many source code files that are using QString such as those given below. But none of these files have directive #include<QString>. I thought adding the line #include<QString> will make the error go away but it unfortunately it stays.

                "
                foreach(const QString &preset, presets)
                {
                QStringList temp = preset.split(";");
                m_ui->presetComboBox->addItem(temp[0], temp[1] + ":" + temp[2]);
                }

                "

                or
                "
                void DateTimeWidget::on_utcOffsetDoubleSpinBox_valueChanged(double d)
                {
                QString prefix("UTC");
                if(d >= 0.0)
                prefix.append("+");

                m_ui->utcOffsetDoubleSpinBox->setPrefix(prefix);
                   
                autoApply();
                

                }

                "

                or
                "
                void CollapsibleDockWidget::updateWindowTitle(QString windowTitle)
                {
                if(_titleBar)
                _titleBar->setWindowTitle(windowTitle);
                }

                "

                S Offline
                S Offline
                SGaist
                Lifetime Qt Champion
                wrote on 17 Jul 2023, 19:43 last edited by
                #6

                Are you using Qt's QStringBuilder ?

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

                A 1 Reply Last reply 17 Jul 2023, 20:18
                0
                • S SGaist
                  17 Jul 2023, 19:43

                  Are you using Qt's QStringBuilder ?

                  A Offline
                  A Offline
                  Alcor
                  wrote on 17 Jul 2023, 20:18 last edited by Alcor
                  #7

                  @SGaist
                  No. Not to the best of my understanding of the code that I am working with. By the way, if it helps, the code I am working with was originally written (compiled and executed successfully for Qt4.8).

                  Just now I found one file with include directive #Include <QtCore/QString>.

                  J 1 Reply Last reply 18 Jul 2023, 07:49
                  0
                  • A Alcor
                    17 Jul 2023, 15:31

                    @JonB

                    "In your original code, prior to whatever line causes the error, do you have something like...."

                    How do I find which line in which file of my code is causing this error?

                    K Offline
                    K Offline
                    kkoehne
                    Moderators
                    wrote on 18 Jul 2023, 07:45 last edited by
                    #8

                    @Alcor said in error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to':

                    How do I find which line in which file of my code is causing this error?

                    Go to the 'Compile Output' pane in Qt Creator. Look for the first "error C2139" . There should be a line with "cl.exe" (the MSVC compiler) before , and that line should contain the name of the source file.

                    Director R&D, The Qt Company

                    1 Reply Last reply
                    2
                    • A Alcor
                      17 Jul 2023, 20:18

                      @SGaist
                      No. Not to the best of my understanding of the code that I am working with. By the way, if it helps, the code I am working with was originally written (compiled and executed successfully for Qt4.8).

                      Just now I found one file with include directive #Include <QtCore/QString>.

                      J Offline
                      J Offline
                      JonB
                      wrote on 18 Jul 2023, 07:49 last edited by
                      #9

                      @Alcor
                      First please follow @kkoehne's suggestion.

                      It might be time now for you to create a brand new, standalone project in Creator. Keep it tiny, put #include <QString> at the head of the .cpp file and QString temp; somewhere inside a function. As little else as possible. Try to just compile. Does that work or generate errors?

                      1 Reply Last reply
                      0
                      • W Offline
                        W Offline
                        WWebber
                        wrote 22 days ago last edited by WWebber
                        #10

                        I ran into exactly the same problem!
                        Porting from V5.12.x (VS2019) to V6.5.3 (VS2022).
                        How did you fix this?
                        The project works perfect with VS2019!
                        The problem is that the error message does not point to any useful source file than "type_traits".

                        1 Reply Last reply
                        0
                        • aha_1980A Offline
                          aha_1980A Offline
                          aha_1980
                          Lifetime Qt Champion
                          wrote 21 days ago last edited by
                          #11

                          @WWebber: Have you tried the suggestion from @kkoehne in https://forum.qt.io/post/765260 ?

                          Qt has to stay free or it will die.

                          W 1 Reply Last reply 21 days ago
                          0
                          • aha_1980A aha_1980
                            21 days ago

                            @WWebber: Have you tried the suggestion from @kkoehne in https://forum.qt.io/post/765260 ?

                            W Offline
                            W Offline
                            WWebber
                            wrote 21 days ago last edited by
                            #12

                            @aha_1980 said in error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to':

                            @WWebber: Have you tried the suggestion from @kkoehne in https://forum.qt.io/post/765260 ?

                            It points to 'type_traits' and to exactly this line:

                            struct is_convertible : bool_constant<__is_convertible_to(_From, _To)> {
                            // determine whether _From is convertible to _To
                            };

                            1>C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\type_traits(323,39): error C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'
                            1>(compiling source file '../QT/test.cpp')
                            1> c:\Qt6\6.5.3\msvc2019_64\include\QtCore\qcontainerfwd.h(30,7):
                            1> see declaration of 'QString'
                            1> C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Tools\MSVC\14.43.34808\include\type_traits(323,39):
                            1> the template instantiation context (the oldest one first) is
                            1> c:\Qt6\6.5.3\msvc2019_64\include\QtCore\qstringtokenizer.h(27,30):
                            1> while compiling class template member function 'QAnyStringView::QAnyStringView(Container &&,wrapped<Container,QString>::type &&)'
                            1> c:\Qt6\6.5.3\msvc2019_64\include\QtCore\qstringtokenizer.h(27,30):
                            1> while processing the default template argument of 'QAnyStringView::QAnyStringView(Container &&,wrapped<Container,QString>::type &&)'
                            1> c:\Qt6\6.5.3\msvc2019_64\include\QtCore\qanystringview.h(216,35):
                            1> see reference to alias template instantiation 'QAnyStringView::if_convertible_to<QString,QStringTokenizerBaseBase::tokenizer_state&>' being compiled
                            1> c:\Qt6\6.5.3\msvc2019_64\include\QtCore\qanystringview.h(82,53):
                            1> see reference to variable template 'const bool conjunction_v<std::negation<std::disjunction<std::is_same<QStringTokenizerBaseBase::tokenizer_state,enum QAnyStringView::Tag>,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QAnyStringView,std::is_pointerQStringTokenizerBaseBase::tokenizer_state,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QByteArray,std::is_sameQStringTokenizerBaseBase::tokenizer_state,QString > >,std::is_convertible<QStringTokenizerBaseBase::tokenizer_state &,QString> >' being compiled
                            1> c:\Qt6\6.5.3\msvc2019_64\include\QtCore\qanystringview.h(82,53):
                            1> see reference to class template instantiation 'std::is_convertible<QStringTokenizerBaseBase::tokenizer_state &,QString>' being compiled

                            1 Reply Last reply
                            0
                            • W Offline
                              W Offline
                              WWebber
                              wrote 21 days ago last edited by
                              #13

                              The error shows up with an empty CPP file holding just this single line:
                              #include <qdialog.h>

                              1 Reply Last reply
                              0
                              • Christian EhrlicherC Offline
                                Christian EhrlicherC Offline
                                Christian Ehrlicher
                                Lifetime Qt Champion
                                wrote 21 days ago last edited by
                                #14

                                Use a recent Qt version and add the include to QString before.

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

                                W 1 Reply Last reply 21 days ago
                                0
                                • Christian EhrlicherC Christian Ehrlicher
                                  21 days ago

                                  Use a recent Qt version and add the include to QString before.

                                  W Offline
                                  W Offline
                                  WWebber
                                  wrote 21 days ago last edited by
                                  #15

                                  @Christian-Ehrlicher said in error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to':

                                  Use a recent Qt version and add the include to QString before.

                                  This is unfortunately not an option as I write a DLL for a main application using V6.5.3.
                                  Even when I just include <qstring> in the testcpp, I'm gettig the same error.

                                  1 Reply Last reply
                                  0
                                  • Christian EhrlicherC Offline
                                    Christian EhrlicherC Offline
                                    Christian Ehrlicher
                                    Lifetime Qt Champion
                                    wrote 21 days ago last edited by
                                    #16

                                    Simply try a recent version to see if it works...

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

                                    1 Reply Last reply
                                    0
                                    • W Offline
                                      W Offline
                                      WWebber
                                      wrote 18 days ago last edited by
                                      #17

                                      Tested with the latest 6.x version - same error.
                                      I suspect it has to do with the latest QT Tools..

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

                                        Try it with a simple CMakeLists.txt on thee visual studio command line.

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

                                        1 Reply Last reply
                                        0
                                        • W Offline
                                          W Offline
                                          WWebber
                                          wrote 17 days ago last edited by
                                          #19

                                          Found it!
                                          This error was caused by the compiler option "/Zc:hiddenFriend-" !

                                          1 Reply Last reply
                                          2
                                          • S SGaist has marked this topic as solved 16 days ago

                                          • Login

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