Qt-interest Archive, February 2007
Basic Qextserialport question
Message 1 in thread
Thank you for reading this.
I was very interested in the recent message posted by Stuart Nixon since
this is an area that I have struggled with for some time.
Should the following code work with Qt3 or is it only compatible with Qt4?
I'd like to be able to both read and write single characters plus read back
a block of characters.
serial->setBaudRate(BAUD4800);
serial->setParity(PAR_NONE);
serial->setDataBits(DATA_8);
serial->setStopBits(STOP_1);
serial->setName("/dev/ttyS0");
char buffer[20];
char d = serial->(QIODevice::getch());
if(serial->open(QIODevice::IO_ReadOnly)) //I added "IO_"
{
// .. read stuff
}
The first two errors refer to the "getch" line and the third refers to the
"open" line.
/home/phil/serialtest/src/serialtest.cpp:57: error: expected unqualified-id
before '(' token
/home/phil/serialtest/src/serialtest.cpp:57: error: cannot call member
function 'virtual int QIODevice::getch()' without object
/home/phil/serialtest/src/serialtest.cpp:59: error: expected unqualified-id
before numeric constant
Regards,
Phil.
--
[ signature omitted ]
Message 2 in thread
Hi,
> char d = serial->(QIODevice::getch());
Change to:
char d = serial->getch();
> if(serial->open(QIODevice::IO_ReadOnly)) //I added "IO_"
In Qt 4 use QIODevice::ReadOnly instead of QIODevice::IO_ReadOnly.
--
[ signature omitted ]