error: C2139: 'QString': an undefined class is not allowed as an argument to compiler intrinsic type trait '__is_convertible_to'
-
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 compiledI have also attached the screenshot of the Qt Creator Screen. Please help me as I have no clue about it.
-
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);
}"
-
@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>.
-
@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.
-
@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 andQString temp;
somewhere inside a function. As little else as possible. Try to just compile. Does that work or generate errors?