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. Porting lowenergyscanner example. [SOLVED]

Porting lowenergyscanner example. [SOLVED]

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 1.8k Views 2 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.
  • J Offline
    J Offline
    jenya7
    wrote on last edited by jenya7
    #1

    I create QT Widgets Application. Include in projects the following files:
    device.cpp
    deviceinfo.cpp
    serviceinfo.cpp
    characteristicinfo.cpp
    device.h
    deviceinfo.h
    serviceinfo.h
    characteristicinfo.h

    Build it without errors.
    Then in mainwindow.cpp I add :

    void MainWindow::on_pushButtonScan_clicked()
    {
    QBluetoothDeviceDiscoveryAgent discoveryAgent = new BluetoothDeviceDiscoveryAgent();
    discoveryAgent.start();
    }

    But when I build I get some errors:

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall QBluetoothDeviceDiscoveryAgent::QBluetoothDeviceDiscoveryAgent(class QObject *)" (_imp??0QBluetoothDeviceDiscoveryAgent@@QAE@PAVQObject@@@Z) referenced in function "private: void __thiscall MainWindow::on_pushButtonScan_clicked(void)" (?on_pushButtonScan_clicked@MainWindow@@AAEXXZ)

    mainwindow.obj:-1: error: LNK2019: unresolved external symbol "__declspec(dllimport) public: virtual __thiscall QBluetoothDeviceDiscoveryAgent::~QBluetoothDeviceDiscoveryAgent(void)" (_imp??1QBluetoothDeviceDiscoveryAgent@@UAE@XZ) referenced in function "public: virtual void * __thiscall QBluetoothDeviceDiscoveryAgent::`scalar deleting destructor'(unsigned int)" (??_GQBluetoothDeviceDiscoveryAgent@@UAEPAXI@Z)

    mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual struct QMetaObject const * __thiscall QBluetoothDeviceDiscoveryAgent::metaObject(void)const " (?metaObject@QBluetoothDeviceDiscoveryAgent@@UBEPBUQMetaObject@@XZ)

    mainwindow.obj:-1: error: LNK2001: unresolved external symbol "public: virtual int __thiscall QBluetoothDeviceDiscoveryAgent::qt_metacall(enum QMetaObject::Call,int,void * *)" (?qt_metacall@QBluetoothDeviceDiscoveryAgent@@UAEHW4Call@QMetaObject@@HPAPAX@Z)

    What’s wrong with my code?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

      QT += bluetooth

      1 Reply Last reply
      1
      • J Offline
        J Offline
        jenya7
        wrote on last edited by
        #3

        Is it supposed to mean something?

        mrjjM 1 Reply Last reply
        0
        • J jenya7

          Is it supposed to mean something?

          mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by mrjj
          #4

          @jenya7
          Yes it means, open the .pro file (the project file)
          and insert that line on top
          It adds the module called bluetooth
          Often it already adds gui that way.
          like
          QT += core gui
          so you just add it to the line (only bluetooth)
          or on its own line with full syntax as he wrote.

          small note:

          QBluetoothDeviceDiscoveryAgent *discoveryAgent = new BluetoothDeviceDiscoveryAgent();
          discoveryAgent.start(); <<--
          should be 
          discoveryAgent->start();
          
          1 Reply Last reply
          1
          • J Offline
            J Offline
            jenya7
            wrote on last edited by
            #5

            Thank you very much. It solved the problem.

            mrjjM 1 Reply Last reply
            0
            • J jenya7

              Thank you very much. It solved the problem.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @jenya7
              super.
              Now we just hope it actually discovers some devices :)

              1 Reply Last reply
              0
              • J Offline
                J Offline
                jenya7
                wrote on last edited by
                #7

                Actually when I run the original example, and click the Search button it informs me - An unknown error has occurred.

                mrjjM 1 Reply Last reply
                0
                • J jenya7

                  Actually when I run the original example, and click the Search button it informs me - An unknown error has occurred.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @jenya7 said:

                  An unknown error has occurred.

                  Well you do have bluetooth in pc you run it on ?

                  ahh. it doesn't support windows at all.
                  https://forum.qt.io/topic/46338/bluetooth-device-discovery-not-working/3

                  1 Reply Last reply
                  0
                  • J Offline
                    J Offline
                    jenya7
                    wrote on last edited by
                    #9

                    I see. Thank you.

                    1 Reply Last reply
                    0

                    • Login

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