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 with USB
Forum Update on Monday, May 27th 2025

QT with USB

Scheduled Pinned Locked Moved General and Desktop
usb qt
5 Posts 3 Posters 3.3k 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.
  • Y Offline
    Y Offline
    youfulan2015
    wrote on 24 Jul 2015, 06:25 last edited by
    #1

    HI ,guys
    I get job last week;the Manager want me to transplant a vc6 project into Qt;
    I got all the codes;
    but here is a question I come across:
    in vc6 we can send a control message to a usb device by function "DeviceIoControl" in MSDN:
    DeviceIoControl
    The DeviceIoControl function sends a control code directly to a specified device driver, causing the corresponding device to perform the corresponding operation.

    BOOL DeviceIoControl(
    HANDLE hDevice, // handle to device
    DWORD dwIoControlCode, // operation
    LPVOID lpInBuffer, // input data buffer
    DWORD nInBufferSize, // size of input data buffer
    LPVOID lpOutBuffer, // output data buffer
    DWORD nOutBufferSize, // size of output data buffer
    LPDWORD lpBytesReturned, // byte count
    LPOVERLAPPED lpOverlapped // overlapped information
    );
    I found this funcjtion in the vc project .but for a Qt project how to write/read datas into a USB device?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on 24 Jul 2015, 07:32 last edited by
      #2

      This DeviceIoControl() function is a part of Win32 API, and does not related to Qt at all. So, you can use this function as well as in VS. Please read the MSDN to find out a Win-API headers which need to include to your project.

      Y 1 Reply Last reply 24 Jul 2015, 07:46
      0
      • K kuzulis
        24 Jul 2015, 07:32

        This DeviceIoControl() function is a part of Win32 API, and does not related to Qt at all. So, you can use this function as well as in VS. Please read the MSDN to find out a Win-API headers which need to include to your project.

        Y Offline
        Y Offline
        youfulan2015
        wrote on 24 Jul 2015, 07:46 last edited by
        #3

        @kuzulis
        another question I got DLL build by vc6 ,here is the function inside:
        #ifndef DLL_API
        #define DLL_API extern "C" __declspec(dllimport)
        #endif

        #define WIN_API __stdcall

        ....................
        DLL_API void WINAPI HTDrawTopPentagon(HDC hDC,int nCenterX,int nCenterY,COLORREF clr);
        ...................
        in QT I wang to use these funtions.
        will it work if I program like this:
        "
        QLibrary myLib("dll_name");

        typedef int (*MyPrototype)(QPixmap* ,int,int,QColor);
        MyPrototype myFunction = (MyPrototype) myLib.resolve("HTDrawTopPentagon");
        

        myFunction test;
        will test work?
        or should i typedef int (*MyPrototype)(HDC ,int,int,COLORREF);in QT?

        1 Reply Last reply
        0
        • K Offline
          K Offline
          kuzulis
          Qt Champions 2020
          wrote on 24 Jul 2015, 08:20 last edited by
          #4

          or should i typedef int (*MyPrototype)(HDC ,int,int,COLORREF);in QT?

          yes

          1 Reply Last reply
          0
          • J Offline
            J Offline
            Jeroentjehome
            wrote on 24 Jul 2015, 09:42 last edited by
            #5

            Hi,
            Because Qt is cross platform using a WinAPI is bad form. Shouldn't you switch to libusb making it cross platform?

            Greetz, Jeroen

            1 Reply Last reply
            0

            2/5

            24 Jul 2015, 07:32

            • Login

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