I'm trying to build a sample project using Qt 5.7 over Linux. Previously, the same project have been built with Qt 5.4.2 without issues. When I try with Qt 5.7, I get the followings errors:
undefined reference to `QJsonValue::toString() const'
I have tried installing Qt5.7 with Qt Maintenance Tool and also download from Qt official site and install it using .run file. When I run a locate to qjsonvalue I get the followings results:
$ locate qjsonvalue
/opt/Qt/5.4/Src/qtbase/include/QtCore/qjsonvalue.h
/opt/Qt/5.4/Src/qtbase/src/corelib/json/qjsonvalue.cpp
/opt/Qt/5.4/Src/qtbase/src/corelib/json/qjsonvalue.h
/opt/Qt/5.4/android_armv7/include/QtCore/qjsonvalue.h
/opt/Qt/5.4/android_x86/include/QtCore/qjsonvalue.h
/opt/Qt/5.4/gcc_64/include/QtCore/qjsonvalue.h
/usr/include/qt5/QtCore/qjsonvalue.h
/usr/share/doc/qt5/qtcore/qjsonvalue-members.html
/usr/share/doc/qt5/qtcore/qjsonvalue.html
According with the previous results, seems that I need to install something becuase qjsonvalue.h/cpp is not in my Qt5.7 core. Any ideas about how to solve it? Need to install anything else? As note, when I start Qt Maintenance Tool I get an alert message that says the following:
Your installation seems to be corrupted. Please consider re-installing from scratch.
Found this comming here via google. I had the same issue.
The API changed from a default argument
QString QJsonValue::toString(const QString & defaultValue = QString()) const
to two overloads.
QString QJsonValue::toString() const
QString QJsonValue::toString(const QString &defaultValue) const
You should build with the headers of the oldest version you want to support. But if you just need this one error fixed you can just change the call from
QJsonValue someval;
QString str = someval.toString();
to
QString str = someval.toString(QString());
But you will probably get some other linker error in the wake of fixing this one.
Related
I want to learn Qt especially for the 3D functionalities and therefore was following this tutorial.
One part of the tutorial is displaying the mesh from a .dae file called object.dae.
When I tried to run my code for the first time, I got the following error:
2:25:52: Starting /home/qt/build-Qt3DTests-Desktop_Qt_5_15_2_GCC_64bit-Debug/Qt3DTests ...
Qt3D.Renderer.SceneLoaders: Qt3DCore::QEntity* Qt3DRender::Render::LoadSceneJob::tryLoadScene(Qt3DRender::QSceneLoader::Status&, const QStringList&, const std::function<void(Qt3DRender::QSceneImporter*)>&) Found no suitable importer plugin for QUrl("file:../Qt3DTests/Models/object1.dae")
22:26:00: /home/qt/build-Qt3DTests-Desktop_Qt_5_15_2_GCC_64bit-Debug/Qt3DTests exited with code 0
I proceeded to clone the repo (tag: STEP_001) and try running it but again I receive the same error.
As this was the first Qt tutorial and C++ code I ever did, I am unsure what could be the problem. Does anybody know what is going wrong? Am I missing some module in my installation or something?
The cause might be this (rare) bug in Qt:
https://bugreports.qt.io/browse/QTBUG-89045
I'm trying to make static compile of my QT application. I almost've done it but there is one problem I can't resolve (I couldn't find any similar problem in google). Error looks like this:
path/libQt5Core.a(qthread.o):qthread.cpp:(.text$_ZN19QThreadCreateThread3runEv[_ZN19QThreadCreateThread3runEv]+0x57): undefined reference to `std::condition_variable::wait(std::unique_lock<std::mutex>&)'
I've added "LIBS += -pthread" to my project file but it's still not working.
I'm working on Windows 8.1.
I have no idea why this is happening. But everytime I compile my application with a couple of the Qt versions that I have installed I now get these warnings:
In file included from /home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qbrush.h:50,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qpalette.h:46,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtWidgets/qwidget.h:48,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtWidgets/qdesktopwidget.h:44,
from /home/Qt5.9.2/5.9.2/gcc_64/include/QtWidgets/QDesktopWidget:1,
from ../src/../../CommonClasses/SQLConn/../../CommonClasses/common.h:6,
from ../src/../../CommonClasses/SQLConn/dbinterface.h:10,
from ../src/../../EyeExperimenter/src/sslclient/sslclient.h:10,
from ../src/../../EyeExperimenter/src/sslclient/ssldbclient.h:4,
from ../src/sslwrapper.h:6,
from ../src/main.cpp:3:
/home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qtransform.h: In member function ‘QTransform& QTransform::operator=(QTransform&&)’:
/home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qtransform.h:81:46: warning: ‘void* memcpy(void*, const void*, size_t)’ writing to an object of type ‘class QTransform’ with no trivial copy-assignment; use copy-assignment or copy-initialization instead [-Wclass-memaccess]
{ memcpy(this, &other, sizeof(QTransform)); return *this; }
^
/home/Qt5.9.2/5.9.2/gcc_64/include/QtGui/qtransform.h:57:20: note: ‘class QTransform’ declared here
class Q_GUI_EXPORT QTransform
Can any one tell me what this warning is and, more importantly, how do I get rid of it? From what I've seen it has to do with gcc8 which my system currently has, however I've tried chaging the compiler in the Qt Kits configuration of QtCreator and the warning still appears...
You use qmake as the build system generator, and then gnu make to actually build stuff - Qt Creator is just a shortcut from typing it all out on the command line :)
You can pass the relevant flag to the compiler by adding the following to your .pro file, then re-running qmake on the project (e.g. delete the build folder and build again):
QMAKE_CFLAGS_WARN_ON += -Wno-class-memaccess
QMAKE_CXXFLAGS_WARN_ON += -Wno-class-memaccess
QMAKE_CFLAGS += -Wno-class-memaccess
QMAKE_CXXFLAGS += -Wno-class-memaccess
I have built a QWidgets application in Qt 5.3.1 and in some places have used
qDebug() << msg;
where msg is a QString.
I had had this compiling and running for a few years, but tonight I decided to recompile it and I got the message:
D:\devt\myapp\extcoder.cpp:29: error: no matching function for call to 'QMessageLogger::debug()'
qDebug()<<msg;
^
In fact I got a similar problem in another app I wrote the other day, and by experimenting I thought I had fixed it by replacing such calls by qDebug(msg).
But it looks as if some kind of software rot is setting in!
Any ideas? Of course the file starts with
#include <QDebug>
To test this problem I built a barebones QWidgets application (of a QMainWindow kind), and the only code I wrote, was (apart from the #include)
qDebug()<<"Hello world";
in the MainWindow constructor. I get exactly the same compilation error.
Reinstallation of Qt made qDebug()<<s work again.
It was indeed a kind of "software rot": I reinstalled qt 5.3.1 after making a copy of the original so I could compare the new with the old.
Using Winmerge I was able to uncover the error:
I dont know exactly how it happened but the file qlogging.h got corrupted.
Here's what happened: at lines 118 and 120 the declarations of two versions of debug got rewritten to NBIS_debug.
Now I have worked trying to port free software from the NBIS. At some stage I must have renamed a debug function from debug to NBIS_debug, and this modification must have been propagated all the way to qlogging.h.
QDebug &QDebug::operator<<(const QString &s) is supported in Qt.
Output example:
QString s;
s = "a";
qDebug().noquote() << s; // prints: a
qDebug() << s; // prints: "a"
Your Qt environment must be broken. Please, check your environment and re-install Qt if needed.
I had to reinstall Ubuntu and Qt. The reinstall only Qt did not help.
Hello I am running Ubuntu 14.04. I have installed qt from the package qt-sdk I have also installed the following package which should have installed the postgres driver:
libqt5sql5-psql
My Qt version is:
Qt Creator 3.0.1 based on Qt 5.2.1
When I try to create a Qt db object of type postgres like so:
QSqlDatabase db = QSqlDatabase::addDatabase(“QPSQL”);
I get a lot of errors like so:
/home/bc/projects/qt_test/main.cpp:12: error: stray '\342' in program
QSqlDatabase db = QSqlDatabase::addDatabase(“QPSQL”);
^
/home/bc/projects/qt_test/main.cpp:12: error: 'QPSQL' was not declared in this scope
QSqlDatabase db = QSqlDatabase::addDatabase(“QPSQL”);
I am obviously not doing something correctly. I don't know what though. Perhaps I am missing a package, or I have mis-configured something.
Help is appreciated.
This isn't a database issue: the compiler is telling you that you have non-ASCII characters in your code that it doesn't recognize:
error: stray '\342' in program
Take care of those and you should at least get as far as compiling.
Use proper quotes, not the fancy ones from some blogs:
QSqlDatabase db = QSqlDatabase::addDatabase("QPSQL");