Results 1 to 2 of 2

Thread: Error on build..QThread class

  1. #1
    Join Date
    May 2009
    Posts
    55
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Error on build..QThread class

    I'm working on my multi-threaded project and got this error on build. I did not require any initialization with my threads and I just made an instance of the thread in the private section of my QMainWindow.
    error: field 'capturingThread' has incomplete type
    error: field 'computingThread' has incomplete type

    The following code is my main window and the error points to the private section here.
    Qt Code:
    1. #ifndef GENIUS_H
    2. #define GENIUS_H
    3.  
    4. #include <QMainWindow>
    5. #include "ui_genius.h"
    6.  
    7. class CapturingThread;
    8. class ComputingThread;
    9.  
    10. class GeniusMain : public QMainWindow, private Ui::genius
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. GeniusMain(QMainWindow *parent);
    16.  
    17. protected:
    18. void closeEvent (QCloseEvent *event);
    19.  
    20. private slots:
    21. void standbyThreads();
    22. void startTransmission();
    23. void haltThreads();
    24. void printFPS();
    25. void printDistance();
    26. void printTeam();
    27. void printOpp();
    28.  
    29. private:
    30. CapturingThread capturingThread;
    31. ComputingThread computingThread;
    32. };
    33.  
    34. #endif
    To copy to clipboard, switch view to plain text mode 

    Here are the header files for my threads capturingThread and computingThread.
    Qt Code:
    1. #ifndef CAPTURINGTHREAD_H
    2. #define CAPTURINGTHREAD_H
    3.  
    4. #include <QThread>
    5.  
    6. class ImageBuffer;
    7.  
    8. class CapturingThread : public QThread
    9. {
    10. public:
    11. CapturingThread();
    12. ~CapturingThread();
    13.  
    14. void haltCapture();
    15.  
    16. protected:
    17. void run();
    18.  
    19. private:
    20. volatile bool halt;
    21. ImageBuffer* imageBuffer;
    22. };
    23.  
    24. #endif
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #ifndef COMPUTINGTHREAD_H
    2. #define COMPUTINGTHREAD_H
    3.  
    4. #include <QThread>
    5.  
    6. class ImageBuffer;
    7.  
    8. class ComputingThread : public QThread
    9. {
    10. public:
    11. ComputingThread();
    12. ~ComputingThread();
    13.  
    14. void haltComputing();
    15. void startTransmitting();
    16. void stopTransmitting();
    17.  
    18. protected:
    19. void run();
    20.  
    21. private:
    22. volatile bool halt;
    23. volatile bool transmit;
    24. ImageBuffer* imageBuffer;
    25. };
    26.  
    27. #endif
    To copy to clipboard, switch view to plain text mode 

    What could be the source of the build error?

  2. #2
    Join Date
    Sep 2009
    Location
    Finland
    Posts
    63
    Thanks
    1
    Thanked 22 Times in 19 Posts
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: Error on build..QThread class

    My guess would be that forward declaration i.e. code below:
    Qt Code:
    1. class CapturingThread;
    2. class ComputingThread;
    To copy to clipboard, switch view to plain text mode 

    Works for pointers but not for objects (see code below).
    Qt Code:
    1. private:
    2. CapturingThread capturingThread;
    3. ComputingThread computingThread;
    To copy to clipboard, switch view to plain text mode 

    So either include both header files (computingthread.h / capturingthread.h) in genius.h file or use next piece of code:
    Qt Code:
    1. private:
    2. CapturingThread *capturingThread;
    3. ComputingThread *computingThread;
    To copy to clipboard, switch view to plain text mode 

    And then allocate the memory for those objects when you need them.

Similar Threads

  1. QT Class GUI Interactions??
    By mikey33 in forum Newbie
    Replies: 3
    Last Post: 19th November 2009, 02:01
  2. class QHBoxLayout
    By csvivek in forum Installation and Deployment
    Replies: 2
    Last Post: 10th April 2008, 07:57
  3. Using QUdpSocket within a QThread
    By db in forum Newbie
    Replies: 18
    Last Post: 30th October 2007, 23:59
  4. Build error on mac Platform::WaitMouseMoved
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 12th July 2007, 13:18
  5. Replies: 2
    Last Post: 27th March 2007, 12:09

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.