Here's my other attempt with the QFile and getch.
void Tech::pushButton1_clicked()
{
{
QFile file( "/dev/ttyS0" );
// Read the text from a file if ( file.open( IO_ReadOnly ) ) {
ErrorText->append( "File opened, trying to read...");
char *a;
while(!file.atEnd())
{
a = file.getch();
line.append( a );
}
file.close();
ErrorText->append( line) ;
ErrorText->append( "File closed");
}
else
{
ErrorText->setText("Could not open file.");
}
}
void Tech::pushButton1_clicked()
{
{
QFile file( "/dev/ttyS0" ); // Read the text from a file
if ( file.open( IO_ReadOnly ) ) {
ErrorText->append( "File opened, trying to read...");
QTextStream stream( &file );
QString line;
char *a;
while(!file.atEnd())
{
a = file.getch();
line.append( a );
}
file.close();
ErrorText->append( line) ;
ErrorText->append( "File closed");
}
else
{
ErrorText->setText("Could not open file.");
}
}
To copy to clipboard, switch view to plain text mode
Not sure why but it gives me compile error:
X10.ui.h:247: error: invalid conversion from `int' to `char*'
X10.ui.h:247: error: invalid conversion from `int' to `char*'
To copy to clipboard, switch view to plain text mode
I'm sure that compile error is somethin stupid though... Still, if you see what's givin me that error lemme know please... :-/
Thanks muchos for the help guys, this has been frustrating me forever.. and by forever i mean almost 4 weeks...
Bookmarks