Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Qt MACRO (not sysinfo) for Windows version?
Forum Updated to NodeBB v4.3 + New Features

Qt MACRO (not sysinfo) for Windows version?

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 4 Posters 1.6k Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wesblake
    wrote on 27 Sept 2018, 01:01 last edited by
    #1

    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
    
    R 1 Reply Last reply 27 Sept 2018, 08:22
    0
    • S Offline
      S Offline
      sierdzio
      Moderators
      wrote on 27 Sept 2018, 05:55 last edited by
      #2

      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.

      (Z(:^

      W 1 Reply Last reply 28 Sept 2018, 21:03
      1
      • W wesblake
        27 Sept 2018, 01:01

        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
        
        R Offline
        R Offline
        raven-worx
        Moderators
        wrote on 27 Sept 2018, 08:22 last edited by raven-worx
        #3

        @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.

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        1 Reply Last reply
        4
        • S sierdzio
          27 Sept 2018, 05:55

          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.

          W Offline
          W Offline
          wesblake
          wrote on 28 Sept 2018, 21:03 last edited by
          #4

          @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

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 28 Sept 2018, 21:27 last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            W 1 Reply Last reply 2 Oct 2018, 22:06
            1
            • S SGaist
              28 Sept 2018, 21:27

              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.

              W Offline
              W Offline
              wesblake
              wrote on 2 Oct 2018, 22:06 last edited by
              #6

              @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!

              1 Reply Last reply
              0

              1/6

              27 Sept 2018, 01:01

              • Login

              • Login or register to search.
              1 out of 6
              • First post
                1/6
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved