PDA

View Full Version : error



sabeesh
27th September 2007, 06:47
hi,
I am facing a problum,
I declare a variable like this in QT.3.2

const QString &node_name
qDebug(">> MyFunction::MYFunction(%s)", (const char *)node_name);

and it is working. But When I copy this line into QT4.3 and make, then it display one error like this,
error: invalid cast from type ‘const QString’ to type ‘const char*’

why? How can I solve this?
please help me....

jpn
27th September 2007, 09:23
Debugging Techniques (http://doc.trolltech.com/4.3/debug.html)

ToddAtWSU
27th September 2007, 14:32
You can't just cast from QString to char* in Qt 4.3. An easy way is instead of saying

(const char *)node_name
for your %s argument, just use


node_name.toStdString( ).c_str( )

This converts from a QString->std::string->const char*. Hope this helps.