How to run CAN Bus example in QtCreator ?
-
wrote on 26 Jul 2022, 13:12 last edited by imene
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) -
wrote on 26 Jul 2022, 14:23 last edited by
Check you have serialbus added in your .pro
QT += serialbus widgets
I found the can example in:
Qt5.xx ▸ Examples ▸ Qt-5.xx ▸ serialbus ▸ can -
Hi @mpergand
QT += serialbus widgets doesn't exist in my .pro file should i uncomment line n°9 ? :
i didn't find serialbus example:
-
wrote on 26 Jul 2022, 15:09 last edited by imene
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
?wrote on 26 Jul 2022, 16:52 last edited by mpergandSeems 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)
wrote on 27 Jul 2022, 11:19 last edited by@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.
-
wrote on 27 Jul 2022, 15:00 last edited by imene
Thanks @mpergand i'm gonna try to implement this example CAN Bus example | Qt Serial Bus 5.15.2 (https://code.qt.io/cgit/qt/qtserialbus.git/tree/examples/serialbus/can?h=5.15.2) i hope it works
1/10