Hi, I'm developing a qt application that interfaces with an external hardware device. My application consists of just 2 start/stop buttons and a listwidget used to display data received from the device. Since the data acquisition from the device requires me to call a blocking function, I've decided to put the call in a separated thread because data acquisition can be stopped only by calling another function from another thread. So I've created this QThread subclass:

Qt Code:
  1. class InventoryThread : public QThread
  2. {
  3. Q_OBJECT
  4.  
  5. private:
  6. int handle;
  7. RFID_18K6C_INVENTORY_PARMS * inventoryParms;
  8. RFID_18K6C_INVENTORY_PARMS * SetInventoryParams(const RFID_RADIO_HANDLE handle, const int cycles);
  9.  
  10. public:
  11. explicit InventoryThread(QObject *parent = 0, int h = 0);
  12.  
  13. protected:
  14. void run();
  15.  
  16. signals:
  17.  
  18. public slots:
  19.  
  20. };
To copy to clipboard, switch view to plain text mode 

The relevant implementation is this:

Qt Code:
  1. InventoryThread::InventoryThread(QObject *parent, int h) :
  2. QThread(parent)
  3. {
  4. handle = h;
  5. }
  6.  
  7. void InventoryThread::run()
  8. {
  9. RFID_18K6CTagInventory(handle, SetInventoryParams(handle, 5), 0);
  10. }
To copy to clipboard, switch view to plain text mode 

The main window code will call InventoryThread::start() when I click on the start button, then RFID_18K6CTagInventory will be called (which is a blocking function). This function can be stopped only by calling RFID_RadioCancelOperation in the main thread. Now, I'm not sure if my approach is correct, the documentation about QThread its main loop il pretty confusing.

What should I do?