I honestly don't know where you are picking up they want you to use QML and QtQuick, if anything in the forum they are suggesting they want to get rid of them, especially QML, which can be a security nightmare according to some of the docs, but they are bound to keep some customers happy. I wonder if we'll see QML in Qt 7
Just read the stuff here: https://doc.qt.io/qt-6/topics-ui.html especially in the comparison table it makes it sound like there is stuff only QML does. In forums I have read people saying that they are pushing QML because it is JavaScript and there are more JavaScript people around than C++ programmers so it's cheaper to hire them and give them something they can do.
really? It's not the impression i had. Guess i was reading different threads
And whatever QML brings to the table, i don't care about (gestures, animations, ...)
at least not for my pc software (the animations I implement are fade in/out or page scrolling, nothing that can't be done in C++)
Re: your endless canbus quest, I did that of course, canbus is nothing special on windows. My interface is from KVaser so i just added the dll and header files to the project. Include the header and call the functions. On linux, i don't know. Probably you need to use the QSerialBus classes? Also, don't know if you need to do anything special if you have an interface supported by QSerialBus
This is one of the few projects i haven't migrated to CMake as it's feature freeze right now. It's still using qmake (and it's easier to add library files there, as you can use the context menu)
You can start single threaded then move the CAN stuff to a different thread. To get the data (available interfaces, data from the bus, ...) send a signal from the CAN stuff, a slot in the GUI element will receive the data and update the GUI. To set the data (select the interface, start, stop, configure, ...) you do the opposite, a signal from the GUI element is connected to a slot in the CAN stuff object.
the .pro file looks like this:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
all my sources
HEADERS += \
all my other headers
kvaser/canevt.h \
kvaser/canlib.h \
kvaser/canstat.h \
kvaser/obsolete.h \
kvaser/predef.h \
FORMS += \
mainwindow.ui \
obdxconfigurationdialog.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
DISTFILES += \
kvaser/canlib32.dll \
kvaser/canlib32.lib
win32: LIBS += -L$$PWD/kvaser/ -lcanlib32
INCLUDEPATH += $$PWD/kvaser
DEPENDPATH += $$PWD/kvaser
win32:!win32-g++: PRE_TARGETDEPS += $$PWD/kvaser/canlib32.lib
#else:win32-g++: PRE_TARGETDEPS += $$PWD/kvaser/libcanlib32.a
For example, to get the list of connected interfaces
MainWindow::~MainWindow() {
if (canHandle >= 0) {
canBusOff(canHandle);
canClose(canHandle);
}
delete ui;
}
void MainWindow::loadCanInterfaceData(void) {
canInitializeLibrary();
//Initialize Data
canHandle = -1;
int nChannels;
canStatus status;
ui->cbCanInterfacesList->clear();
status = canGetNumberOfChannels(&nChannels);
if (status == canStatus::canOK) {
if (nChannels > 0) {
for (int idx=0; idx<nChannels; idx++) {
int deviceChannel;
char deviceName[255];
canGetChannelData(idx, canCHANNELDATA_CHAN_NO_ON_CARD, &deviceChannel, sizeof(deviceChannel));
canGetChannelData(idx, canCHANNELDATA_DEVDESCR_ASCII, deviceName, sizeof(deviceName));
if (!QString(deviceName).contains("Virtual", Qt::CaseInsensitive)) {
ui->cbCanInterfacesList->addItem(QString("%1 - %2 Ch %3").arg(idx+1).arg(deviceName).arg(deviceChannel+1), idx);
}
}
}
}
if (ui->cbCanInterfacesList->count() > 0) {
ui->cbCanInterfacesList->setEnabled(true);
ui->pbSelectCanInterface->setEnabled(true);
}
else {
ui->cbCanInterfacesList->setEnabled(false);
ui->pbSelectCanInterface->setEnabled(false);
}
}
(but here i didn't do more than follow the examples that kvaser provided and adapted them to qt)