PDA

View Full Version : QString ~ QByte error



mhoover
7th March 2006, 19:09
This is probably a stupid mistake on my part, but every time I try to pass a blank QString, the compiler seems to think I have a QByteArray :

"no matching function for call to 'LemonadeCommandClient::LemonadeCommandClient(QByt eArray)'"

I've tried all kinds of different ways of passing it:
lemonade_status( QString::null ) (original)
lemonade_status( QString::Null() )
lemonade_status( QString( "" ) )
lemonade_status((QString)QString::Null())

This is a port from Qt3 to Qt4.

Here is my original constructor:


LemnAdeCmdClient::LemnAdeCmdClient(const QString server)
: LemonadeCommandClient(server.toAscii()),
connect_state(0),
command(QString::null),
lemonade_status(QString::null)


Also, here's another point of confusion on my part. I received this code from someone else. It looks like there's multiple inheritance going on here, but connect_state, command, and lemonade_status seem to be data members. Does that make sense? Also, it seems to accept the QString::null for command, but not for lemonade_status.

Any help?

wysota
7th March 2006, 19:47
This is probably a stupid mistake on my part, but every time I try to pass a blank QString, the compiler seems to think I have a QByteArray :


Maybe because QString::toAscii() returns a QByteArray? Try passing just "server" if you want to have a QString or server.toAscii().data() if you need a const char * (just remember it's a temporary object, so don't store the pointer anywhere).

mhoover
7th March 2006, 20:01
Sweet!

I changed


LemnAdeCmdClient::LemnAdeCmdClient(const QString server)
: LemonadeCommandClient(server.toAscii()),


to:


LemnAdeCmdClient::LemnAdeCmdClient(const QString server)
: LemonadeCommandClient(server.toAscii().data()),

And it worked great! I thought the problem was later because I was getting a different line number from the compile error.
Thanks again, Wysota!