Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: no viable conversion from returned value of type 'int' to function return type 'QString' #4

Open
w5688414 opened this issue Feb 27, 2019 · 2 comments

Comments

@w5688414
Copy link

my QT version is 5.9.7,
mac os system
error occurs when I compile:
sml/smlworkbook.cpp:40:12: error: no viable conversion from returned value of type 'int' to function return type 'QString' return bookViews_raw[0][attribute].toInt(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:219:5: note: candidate constructor not viable: no known conversion from 'int' to 'QChar' for 1st argument QString(QChar c); ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:228:12: note: candidate constructor not viable: no known conversion from 'int' to 'QString &&' for 1st argument inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d ... ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:658:31: note: candidate constructor not viable: no known conversion from 'int' to 'const char *' for 1st argument inline QT_ASCII_CAST_WARN QString(const char *ch) ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:661:31: note: candidate constructor not viable: no known conversion from 'int' to 'const QByteArray &' for 1st argument inline QT_ASCII_CAST_WARN QString(const QByteArray &a) ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:777:12: note: candidate constructor not viable: no known conversion from 'int' to 'const QString::Null &' for 1st argument inline QString(const Null &): d(Data::sharedNull()) {} ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:787:29: note: candidate constructor not viable: no known conversion from 'int' to 'QStringDataPtr' for 1st argument Q_DECL_CONSTEXPR inline QString(QStringDataPtr dd) : d(dd.ptr) {} ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:880:17: note: candidate constructor not viable: no known conversion from 'int' to 'QLatin1String' for 1st argument inline QString::QString(QLatin1String aLatin1) : d(fromLatin1_helper(aLatin1... ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:906:17: note: candidate constructor not viable: no known conversion from 'int' to 'const QString &' for 1st argument inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d) ^ sml/smlworkbook.cpp:40:12: error: no viable conversion from returned value of type 'int' to function return type 'QString' return bookViews_raw[0][attribute].toInt(); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:219:5: note: candidate constructor not viable: no known conversion from 'int' to 'QChar' for 1st argument QString(QChar c); ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:228:12: note: candidate constructor not viable: no known conversion from 'int' to 'QString &&' for 1st argument inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d ... ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:658:31: note: candidate constructor not viable: no known conversion from 'int' to 'const char *' for 1st argument inline QT_ASCII_CAST_WARN QString(const char *ch) ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:661:31: note: candidate constructor not viable: no known conversion from 'int' to 'const QByteArray &' for 1st argument inline QT_ASCII_CAST_WARN QString(const QByteArray &a) ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:777:12: note: candidate constructor not viable: no known conversion from 'int' to 'const QString::Null &' for 1st argument inline QString(const Null &): d(Data::sharedNull()) {} ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:787:29: note: candidate constructor not viable: no known conversion from 'int' to 'QStringDataPtr' for 1st argument Q_DECL_CONSTEXPR inline QString(QStringDataPtr dd) : d(dd.ptr) {} ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:880:17: note: candidate constructor not viable: no known conversion from 'int' to 'QLatin1String' for 1st argument inline QString::QString(QLatin1String aLatin1) : d(fromLatin1_helper(aLatin1... ^ /Users/eric/Qt5.9.7/5.9.7/clang_64/lib/QtCore.framework/Headers/qstring.h:906:17: note: candidate constructor not viable: no known conversion from 'int' to 'const QString &' for 1st argument inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d) ^ 1 error generated. make[3]: *** [.obj/debug/smlworkbook.o] Error 1 make[3]: *** Waiting for unfinished jobs....

@w5688414
Copy link
Author

the solutions: #1

@Sadam452
Copy link

Replace bookViews_raw[0][attribute].toInt()
with
QString::fromStdString(bookViews_raw[0][attribute].toStdString());

GAlexDark added a commit to GAlexDark/QtOfficeOpenXml that referenced this issue Jun 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants