Hi all,
Im am working on a program and have problems with handling a QByteArray string.
When I try to convert that QByteArray string to a QString with
QString newQString = QString(&oldQBytearrayString);
To copy to clipboard, switch view to plain text mode
I do get the following error:
/usr
/include
/QtCore
/qchar.
h:372:8: note
: candidates are
: QChar::QChar(int) <near match>
/usr
/include
/QtCore
/qchar.
h:371:8: note
: QChar::QChar(uint
) <near match>
/usr
/include
/QtCore
/qchar.
h:370:8: note
: QChar::QChar(short int) <near match>
/usr
/include
/QtCore
/qchar.
h:81:12: note
: QChar::QChar(ushort
) <near match>
/usr
/include
/QtCore
/qchar.
h:77:36: note
: QChar::QChar(uchar
) <near match>
/usr
/include
/QtCore
/qchar.
h:76:36: note
: QChar::QChar(char) <near match>
error: conversion from ‘QByteArray*’ to ‘QChar’ is ambiguous
/usr/include/QtCore/qchar.h:372:8: note: candidates are: QChar::QChar(int) <near match>
/usr/include/QtCore/qchar.h:371:8: note: QChar::QChar(uint) <near match>
/usr/include/QtCore/qchar.h:370:8: note: QChar::QChar(short int) <near match>
/usr/include/QtCore/qchar.h:81:12: note: QChar::QChar(ushort) <near match>
/usr/include/QtCore/qchar.h:77:36: note: QChar::QChar(uchar) <near match>
/usr/include/QtCore/qchar.h:76:36: note: QChar::QChar(char) <near match>
To copy to clipboard, switch view to plain text mode
The newQString is the output of a script of me and should be a plain text string.
What is going wrong here?
Code Snippet:
myclass.cpp
void myclass::Thefunction(){
// QProcess *scriptcall; pointer declared as a public member in the class header file
scriptcall -> start("./myscript");
connect(scriptcall, SIGNAL(readyReadStandardOutput()), this, SLOT(Readoutput()));
}
void myclass::Readoutput(){
oldQByteArrayString = scriptcall -> readAllStandardOutput();
QString newQString
= QString(&oldQByteArrayString
);
//this line causes the error
}
void myclass::Thefunction(){
// QProcess *scriptcall; pointer declared as a public member in the class header file
scriptcall = new QProcess(this);
scriptcall -> start("./myscript");
connect(scriptcall, SIGNAL(readyReadStandardOutput()), this, SLOT(Readoutput()));
}
void myclass::Readoutput(){
QByteArray oldQByteArrayString;
oldQByteArrayString = scriptcall -> readAllStandardOutput();
QString newQString = QString(&oldQByteArrayString); //this line causes the error
}
To copy to clipboard, switch view to plain text mode
Additional Information: I can use oldQByteArrayString with a function that requires QSTtring as a parameter without a problem. (QComboBox::addItem( const QString)). When I look at the hex code of oldQByteArray, it contains exactly what I want to be there - 4 ascii code letters, no special chars.
Bookmarks