Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. USB communication in Qt
Forum Update on Monday, May 27th 2025

USB communication in Qt

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
usb qtraspberry piwindows desktop
9 Posts 5 Posters 12.1k Views
  • 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.
  • A Offline
    A Offline
    Andrex_Qt
    wrote on 16 Jul 2019, 11:42 last edited by
    #1

    hi,
    I searched official documentation for USB in Qt and read questions on this forum but no documentation. I want to Send and Receive data from USB of Raspberry pi And USB of Windows PC. I also ran across some web pages like github and typed "" QT += usb "" in project file and i got " Project ERROR: Unknown module(s) in QT: usb ". there should be a better way to achieve this communication.

    J 1 Reply Last reply 16 Jul 2019, 11:49
    0
    • A Andrex_Qt
      16 Jul 2019, 11:42

      hi,
      I searched official documentation for USB in Qt and read questions on this forum but no documentation. I want to Send and Receive data from USB of Raspberry pi And USB of Windows PC. I also ran across some web pages like github and typed "" QT += usb "" in project file and i got " Project ERROR: Unknown module(s) in QT: usb ". there should be a better way to achieve this communication.

      J Online
      J Online
      jsulm
      Lifetime Qt Champion
      wrote on 16 Jul 2019, 11:49 last edited by jsulm
      #2

      @Andrex_Qt said in USB communication in Qt:

      Project ERROR: Unknown module(s) in QT: usb

      Did you build and install that project from GitHub first?
      Also, it is not clear what kind of USB communication you mean.

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply 16 Jul 2019, 11:55
      3
      • J jsulm
        16 Jul 2019, 11:49

        @Andrex_Qt said in USB communication in Qt:

        Project ERROR: Unknown module(s) in QT: usb

        Did you build and install that project from GitHub first?
        Also, it is not clear what kind of USB communication you mean.

        A Offline
        A Offline
        Andrex_Qt
        wrote on 16 Jul 2019, 11:55 last edited by
        #3

        @jsulm
        yes, I did and it didnt work.
        And
        I simply want to send array of bytes serially from my raspberry Pi to PC

        J 1 Reply Last reply 16 Jul 2019, 11:58
        0
        • A Andrex_Qt
          16 Jul 2019, 11:55

          @jsulm
          yes, I did and it didnt work.
          And
          I simply want to send array of bytes serially from my raspberry Pi to PC

          J Online
          J Online
          jsulm
          Lifetime Qt Champion
          wrote on 16 Jul 2019, 11:58 last edited by
          #4

          @Andrex_Qt said in USB communication in Qt:

          serially

          Do you mean serial port? For that there is https://doc.qt.io/qt-5/qtserialport-index.html

          "I did and it didnt work" - you should say what exactly did not work.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          A 1 Reply Last reply 16 Jul 2019, 12:25
          4
          • J jsulm
            16 Jul 2019, 11:58

            @Andrex_Qt said in USB communication in Qt:

            serially

            Do you mean serial port? For that there is https://doc.qt.io/qt-5/qtserialport-index.html

            "I did and it didnt work" - you should say what exactly did not work.

            A Offline
            A Offline
            Andrex_Qt
            wrote on 16 Jul 2019, 12:25 last edited by
            #5

            @jsulm
            ok
            I tried to install following as i am using ubuntu and cros-compilling it
            sudo add-apt-repository ppa:fpoussin/ppa
            sudo apt install libqt5usb5 libqt5usb5-dev
            for libqt5usb5 and libqt5usb5-dev i get "unable to locate package".
            And I want to send data over searially using USB to USB data cable from RPi to PC.

            J P 2 Replies Last reply 16 Jul 2019, 12:41
            0
            • A Andrex_Qt
              16 Jul 2019, 12:25

              @jsulm
              ok
              I tried to install following as i am using ubuntu and cros-compilling it
              sudo add-apt-repository ppa:fpoussin/ppa
              sudo apt install libqt5usb5 libqt5usb5-dev
              for libqt5usb5 and libqt5usb5-dev i get "unable to locate package".
              And I want to send data over searially using USB to USB data cable from RPi to PC.

              J Online
              J Online
              jsulm
              Lifetime Qt Champion
              wrote on 16 Jul 2019, 12:41 last edited by
              #6

              @Andrex_Qt If you're cross compiling then installing Qt packages on your Ubuntu host machine will not help you. You need a sysroot for your target device. Then you cross compile Qt and then the project from GitHub.

              And as I said: if you want serial communication then use https://doc.qt.io/qt-5/qtserialport-index.html

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              4
              • A Andrex_Qt
                16 Jul 2019, 12:25

                @jsulm
                ok
                I tried to install following as i am using ubuntu and cros-compilling it
                sudo add-apt-repository ppa:fpoussin/ppa
                sudo apt install libqt5usb5 libqt5usb5-dev
                for libqt5usb5 and libqt5usb5-dev i get "unable to locate package".
                And I want to send data over searially using USB to USB data cable from RPi to PC.

                P Offline
                P Offline
                Pablo J. Rogina
                wrote on 16 Jul 2019, 13:28 last edited by
                #7

                @Andrex_Qt said in USB communication in Qt:

                sudo add-apt-repository ppa:fpoussin/ppa
                sudo apt install libqt5usb5 libqt5usb5-dev

                These actions will install a pre-built USB module into the machine where you run such commands. As you mentioned you're cross-compiling please be aware that (also mentioned in another reply) installing the library in the host PC won't help you. And I doubt such pre-built library is available for ARM...

                So it leads you to cross-compiling the module on your own. Please follow the steps from github and be aware that libusb-1.0-0-dev and pkg-config packages should be installed in RPi device and then rsync to the host PC before cross-compiling.

                Once you succeed installing the module, you need to rsync again from host PC to RPi so the module is available in the device.

                Also check the examples from Qt USB module for further reference.

                Upvote the answer(s) that helped you solve the issue
                Use "Topic Tools" button to mark your post as Solved
                Add screenshots via postimage.org
                Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

                1 Reply Last reply
                3
                • K Offline
                  K Offline
                  kuzulis
                  Qt Champions 2020
                  wrote on 17 Jul 2019, 07:18 last edited by kuzulis
                  #8

                  @Andrex_Qt said in USB communication in Qt:

                  I want to Send and Receive data from USB of Raspberry pi And USB of Windows PC.

                  I'm think, it is not possible. AFAIK, the USB specification declares the 'master-slave' approach. I.e. a master is a host, and a slave is a device (or other think).

                  So, from your case you need to configure your RPi as a OTG device - it will be a slave (seems a linux allows to do it), and the Windows PC will be as a host. So, only a host will send a requests to the slave. I want to say, that I'm not sure that a libusb (or other xxx_usb library) will help you due to specific of a USB bus.

                  I'm think that a simplest way is to configure your RPi as a Serial/Gadget device . In this case, from the RPi side you will work with a "virtual" serial port (e.g. ttyGS0). From the Windows PC you will work with a serial ports too (when you will connect the RPi to the PC, than your RPi will be detected as a serial port in Windows device manager).

                  But, I'm never tried this.

                  1 Reply Last reply
                  1
                  • F Offline
                    F Offline
                    Fpoussin
                    wrote on 17 Jul 2019, 09:07 last edited by Fpoussin
                    #9

                    Hi,

                    I'm the author of QtUsb.
                    The modular version (0.5) is on beta and not available on ppa (0.4.2) yet. I'll work on that.

                    Feel free to open issues on github if you find any bugs.

                    Edit: it should be good for bionic and newer.

                    1 Reply Last reply
                    6

                    9/9

                    17 Jul 2019, 09:07

                    • Login

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