Results 1 to 3 of 3

Thread: QString ~ QByte error

  1. #1
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QString ~ QByte error

    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:
    Qt Code:
    1. LemnAdeCmdClient::LemnAdeCmdClient(const QString server)
    2. : LemonadeCommandClient(server.toAscii()),
    3. connect_state(0),
    4. command(QString::null),
    5. lemonade_status(QString::null)
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QString ~ QByte error

    Quote Originally Posted by mhoover
    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).

  3. The following user says thank you to wysota for this useful post:

    mhoover (7th March 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Maui, Hawaii
    Posts
    120
    Thanks
    65
    Thanked 4 Times in 4 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Smile Re: QString ~ QByte error

    Sweet!

    I changed
    Qt Code:
    1. LemnAdeCmdClient::LemnAdeCmdClient(const QString server)
    2. : LemonadeCommandClient(server.toAscii()),
    To copy to clipboard, switch view to plain text mode 

    to:
    Qt Code:
    1. LemnAdeCmdClient::LemnAdeCmdClient(const QString server)
    2. : LemonadeCommandClient(server.toAscii().data()),
    To copy to clipboard, switch view to plain text mode 
    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!

Similar Threads

  1. nmake error during .pro compiling
    By mattia in forum Installation and Deployment
    Replies: 5
    Last Post: 18th June 2008, 10:15
  2. Compile 4.4.0
    By LordQt in forum Installation and Deployment
    Replies: 18
    Last Post: 29th May 2008, 13:43
  3. QPSQL driver in windows
    By brevleq in forum Installation and Deployment
    Replies: 31
    Last Post: 14th December 2007, 12:57
  4. Error compiling psql plugin
    By vieraci in forum Installation and Deployment
    Replies: 4
    Last Post: 7th October 2007, 02:49
  5. Convert from iso-8859-1 to... Something else :-)
    By Nyphel in forum Qt Programming
    Replies: 4
    Last Post: 7th March 2007, 17:59

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.