How to run CAN Bus example in QtCreator ?
-
Hello,
I want to run CAN Bus example in QtCreator but it doesn't exist in QtCreator examples list !
https://stuff.mit.edu/afs/athena/software/texmaker_v5.0.2/qt57/doc/qtserialbus/qtserialbus-can-example.htmlThis is what i get when i implement it as a new project:
OS: Raspbian GNU/Linux 11 (bullseye) [linux version 5.15.53-v7+]
Qt Creator 4.14.1
Based on Qt 5.15.2 (GCC 10.2.1 20210110, 32 bit) -
Hi @mpergand
QT += serialbus widgets doesn't exist in my .pro file should i uncomment line n°9 ? :
i didn't find serialbus example:
-
Hi @JonB
i've made a mistake, i forget to past the right code of .pro from the site this is the right one contain QT += serialbus widgets :
Now i'm facing those issues "invalid initiazation of reference of type 'const QByteArray&' from expression of type 'const QString'":
-
Hi @JonB
i've made a mistake, i forget to past the right code of .pro from the site this is the right one contain QT += serialbus widgets :
Now i'm facing those issues "invalid initiazation of reference of type 'const QByteArray&' from expression of type 'const QString'":
-
@imene
I know nothing about this, but look at your line #199 (connectdialog.cpp
, your code?). I see something like an attempt to use aQByteArray &
to iterate through aQStringList
?Seems you're using an old version, from the version in Qt 5.12, I see no usage of Q_FOREACH nor QByteArray in ConnectDialog.
It seems in the new version, it looks like that:
for (const QCanBusDeviceInfo &info : qAsConst(m_interfaces)) {
And @JonB guessing right, m_interfaces is a QList of QCanBusDeviceInfo
I suggest you to update to a newer version to avoid unnecessary headaches.
-
Hi @mpergand i can't make an update it's already the newest version available under debian(bullseye) OS Qt 5.15.2 (GCC 10.2.1 20210110, 32 bit)
@imene
You are using an incompatible version of the CAN example with Qt 5.15, because of that:
In Qt 5.6 QCanBus classQList<QByteArray> plugins() const;
In Qt 5.15 :
QStringList QCanBus::plugins() const
The CAN example you are using is not the one provide with Qt 5.15 and you must use the right one otherwise it doesn't compile.