Qt MACRO (not sysinfo) for Windows version?
-
Hi all. So I've got this bluetooth code working under Windows 10 and Mac, but now need it to compile and work again under Windows <= 10 (sucks the bluetooth libs are so limited at this day an age!)
Anyways, I have the following code which compiles fine but if I replace the qDebug with the new QBluetoothLocalDevice, the program crashes on Win7 immediately.
Problem is, the line probably has to be left out of compilation completely for <= 10 but I can't find any macro's like that in the example for Mac to differentiate Windows versions, so how would one even do this or use the Bluetooth library at all then??
Thanks#ifdef Q_OS_MAC localDevice = new QBluetoothLocalDevice(this); #else if(QSysInfo::windowsVersion()>=QSysInfo::WV_WINDOWS10) qDebug() << "WTF";//localDevice = new QBluetoothLocalDevice(this); #endif
-
Move your bluetooth code into a plugin and only load it if you detect proper Windows version.
There is no specific macro for windows versions.
-
@wesblake
macros are for compile time.
Since you can't explicitly target a windows version and various windows versions can run the same binary a macro wouldn't help you anyway here. -
@sierdzio said in Qt MACRO (not sysinfo) for Windows version?:
Move your bluetooth code into a plugin and only load it if you detect proper Windows version.
There is no specific macro for windows versions.
Thanks, I'm looking into creating a plugin, never done it before. My first hurdle it looks like is that you must subclass a plugin base class. There doesn't seem to be too much info here so I'm not sure which would be the best for Bluetooth: http://doc.qt.io/qt-5/plugins-howto.html
-
Hi,
That's an application specific plugin (that will be using the bluetooth module) that you are writing so the The Low-Level API: Extending Qt Applications is the part you should look into.
-
@SGaist said in Qt MACRO (not sysinfo) for Windows version?:
Hi,
That's an application specific plugin (that will be using the bluetooth module) that you are writing so the The Low-Level API: Extending Qt Applications is the part you should look into.
That worked great, thanks! I was able to move all my code into a plugin and now our BT device works on Mac and Windows 10, other Windows still run.
Do we have any idea of the roadmap/timeframe when QBluetooth will support older versions of Windows? I still have to support Windows 7+, I've found no other method in Qt to talk to the BT device. I'd like to be able to simply say, "we'll have support when Qt 5.12 comes out" or similar. Thanks again!