Results 1 to 6 of 6

Thread: Using QIODevice to read a GPS filenode?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Using QIODevice to read a GPS filenode?

    Hello people,

    i am trying to achieve programmatically an async read on a IO node file which receives the outputs of a NMEA GPS.

    i have tried to subclass QIODevice like this (For testing):
    Qt Code:
    1. #include "QIOGpsReader.h"
    2. #include <QIODevice>
    3.  
    4. QIOGpsReader::QIOGpsReader (QString node, QObject *parent) : QIODevice(parent) {
    5. qDebug("QIOGpsReader::ctor");
    6. }
    7.  
    8. QIOGpsReader::~QIOGpsReader (void) {
    9. qDebug("QIOGpsReader::~ctor");
    10. }
    11.  
    12. qint64 QIOGpsReader::readData (char *data, qint64 maxSize) {
    13. qDebug("QIOGpsReader::readData");
    14. strcpy(data, "1");
    15. return 1;
    16. }
    17.  
    18. qint64 QIOGpsReader::writeData (const char *data, qint64 maxSize) {
    19. qDebug("QIOGpsReader::writeData");
    20. return 0;
    21. }
    22.  
    23. qint64 QIOGpsReader::bytesAvailable (void) const {
    24. qDebug("QIOGpsReader::bytesAvailable");
    25. return 1;
    26. }
    To copy to clipboard, switch view to plain text mode 

    Then in my main routine i instanciate a QIOGpsReader object and just connect the readyRead signal to a slot. Then i do a open(QIODevice::ReadOnly) "just to do it".

    What i dont understand is, on what is based the "readReady" signal? When i look to my debug, i don't see any of my qDebug messages... What will make the QIODevice trigger a readyRead signal? i thought at a first that returning always 1 from readData and bytesAvailable would "tell" the QIODevice that it has to trigger, but it doesnt...

    Basically, what is the method i have to reimplement which will tell the QIODevice object to signal a readReady event?

    Thanks,
    Pierre.

    [EDIT:] i think it will not help but anyway here is my .h for my subclass:
    Qt Code:
    1. #ifndef QIOGpsReader_h
    2. #define QIOGpsReader_h
    3.  
    4. #include <QIODevice>
    5.  
    6. class QIOGpsReader : public QIODevice {
    7.  
    8. Q_OBJECT
    9.  
    10. public:
    11. QIOGpsReader (QString node, QObject *parent);
    12. ~QIOGpsReader (void);
    13.  
    14. protected:
    15. qint64 readData (char*, qint64);
    16. qint64 writeData (const char *data, qint64 maxSize);
    17. qint64 bytesAvailable (void) const;
    18. };
    19.  
    20. #endif
    To copy to clipboard, switch view to plain text mode 
    Last edited by hickscorp; 3rd December 2007 at 16:41.

Similar Threads

  1. How to read CD with read?
    By vishal.chauhan in forum Qt Programming
    Replies: 6
    Last Post: 29th June 2007, 08:20
  2. QIODevice read()
    By ShaChris23 in forum Newbie
    Replies: 1
    Last Post: 3rd May 2007, 00:29

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.