Results 1 to 3 of 3

Thread: Thread Problem

  1. #1
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Thread Problem

    Help me por favor!

    I'm trying to implement threading....but it's not working.

    Here's the class that's threaded
    Qt Code:
    1. #ifndef MESSAGER_H
    2. #define MESSAGER_H
    3.  
    4. #include <QString>
    5. #include <QtXml/QDomDocument>
    6. #include <QFile>
    7. #include <QIODevice>
    8. #include <QThread>
    9. #include <QMutex>
    10. #include <QWaitCondition>
    11.  
    12. #include "packet.h"
    13. #include "constants.h"
    14. #include "messager.h"
    15. #include "include/bomMessage.h"
    16.  
    17. class Messager : public QThread
    18. {
    19. Q_OBJECT
    20.  
    21. public:
    22. Messager(QObject *parent = 0);
    23. ~Messager();
    24. bool SetCommand(int MessageType);
    25. bool SetPort(int port);
    26. bool SetBitrate(int rate);
    27. bool SetAddress(int addr);
    28. bool SetValveArray(bool values[]);
    29. bool SetEnabled(bool OnOff);
    30. bool SetDeviceNumber(int Device);
    31. bool SetMessageID(int ID);
    32. bool SetDirection(int Dir);
    33. bool SetRPM(int Speed);
    34. bool SetMultiplier(int Mult);
    35. bool SetOpticType(int Type);
    36. bool SetXMLName(QString name);
    37. bool SetFileName(QString name);
    38. bool SetRecord(bool Enabled);
    39. bool GetReturnValue();
    40.  
    41. public slots:
    42. void GetBowlOpticsStatus(int arrValues[]);
    43.  
    44. protected:
    45. void run();
    46.  
    47. private:
    48. bool Configure();
    49. bool SendGoMessage();
    50. bool SendValveMessage();
    51. bool SendValveStatusMessage();
    52. UINT16 ReadValveStatusMessage();
    53. bool SendMotorMessage();
    54. bool SendMotorStatusMessage();
    55. bool SendSetBowlOpticsMessage();
    56. bool SendBowlOpticsStatusMessage();
    57. UINT16 ReadBowlOpticsStatusMessage();
    58. void StartRecording();
    59. bool LoadScript();
    60. void StopRecording();
    61.  
    62. void GetValves(bool arrOpen[], double values[]);
    63. void OutputToScript(Packet outgoingPacket, int address, int end);
    64. bool SendMessage(Packet outgoing, UINT8 addr);
    65. void OpenXMLFile();
    66. void CloseXMLFile();
    67. bool ReadXMLFile(QIODevice *device, int &PacketNum, Packet packets[], UINT8 addresses[]);
    68. bool SuperScript(Packet packets[], UINT8 addresses[], int PacketNum);
    69.  
    70. bool RECORD;
    71. bool returnValue;
    72. volatile bool stopped;
    73. QString fileName;
    74. QMutex mutex;
    75. QWaitCondition condition;
    76. COMMAND MessageCommand;
    77. int portNum;
    78. int bitrate;
    79. int address;
    80. bool arrOpen[18];
    81. bool Enabled;
    82. int DeviceNumber;
    83. int MessageID;
    84. int Direction;
    85. int RPM;
    86. int Multiplier;
    87. int OpticType;
    88. QString XMLName;
    89. QString FileName;
    90.  
    91. };
    92.  
    93. #endif
    To copy to clipboard, switch view to plain text mode 

    Here's where the class is instantied and accessed.

    Qt Code:
    1. Messager messager;
    2.  
    3. messager.setPort(0);
    4. messager.setBitrate(50);
    5. messager.setCommand(Config);
    6.  
    7. messager.start();
    To copy to clipboard, switch view to plain text mode 

    When I compile I'm getting the following errors returned:

    Qt Code:
    1. decksimulator.cpp: In constructor `DeckSimulator::DeckSimulator(QMainWindow*)':
    2. decksimulator.cpp:74: error: 'class Messager' has no member named 'setPort'
    3. decksimulator.cpp:75: error: 'class Messager' has no member named 'setBitrate'
    4. decksimulator.cpp:76: error: 'class Messager' has no member named 'setCommand'
    To copy to clipboard, switch view to plain text mode 

    The problem is that clearly it does have those members declared...but they are not being seen. What am I doing wrong?

    I can provide more code if necessary.

    Thanks.

    Rob

  2. #2
    Join Date
    Jan 2006
    Location
    La Spezia,Italy
    Posts
    77
    Thanks
    9
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Thread Problem

    Hrmmm,maybe because you called the funcions setPort,setCommand and setRate while the declared ones are SetCommand,SetPort and SetRate?

  3. The following user says thank you to vratojr for this useful post:

    qball2k5 (12th April 2006)

  4. #3
    Join Date
    Mar 2006
    Posts
    26
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread Problem

    HA! How silly of me.....thanks for pointing out to me what was so painfully obvious.

Similar Threads

  1. [thread]how to suspend a work thread
    By viasant in forum Qt Programming
    Replies: 2
    Last Post: 8th April 2013, 17:48
  2. thread - right approach?
    By heinz32 in forum Qt Programming
    Replies: 3
    Last Post: 17th June 2008, 17:39
  3. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 15:31
  4. Terminating a thread.
    By kiranraj in forum Qt Programming
    Replies: 3
    Last Post: 9th July 2007, 11:14
  5. Problem closing a QMainWindow in Qt4.2
    By ian in forum Qt Programming
    Replies: 11
    Last Post: 17th October 2006, 00:49

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.