Results 1 to 7 of 7

Thread: Simple Question about how to put an int to a function that requires coonst QString.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,372
    Thanks
    3
    Thanked 5,019 Times in 4,795 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Simple Question about how to put an int to a function that requires coonst QStrin

    Quote Originally Posted by hakermania View Post
    I get error
    Qt Code:
    1. invalid operands of types ‘const char*’ and ‘const char [7]’ to binary ‘operator+’
    To copy to clipboard, switch view to plain text mode 

    So, how will I do what I want?
    Note that the error is a little misleading. Although it complains about character strings, the real problem is the integer you are passing somewhere in the middle.

    As for the + operator, it is good to always wrap all C strings into QLatin1String. It's a bit of more work but it has some benefits for more complex applications. There is not operator+ defined for it though, so it's likely you'd get some different error then too but at least the compiler wouldn't try to add an integer to your string.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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

    hakermania (6th January 2011)

Similar Threads

  1. QString function by value
    By hmarani in forum Newbie
    Replies: 6
    Last Post: 24th November 2010, 10:01
  2. call function as Qstring
    By jcr in forum Qt Programming
    Replies: 1
    Last Post: 30th May 2009, 01:35
  3. Method/Function With QString Arg
    By seanmu13 in forum Qt Programming
    Replies: 2
    Last Post: 7th July 2007, 09:43
  4. simple QString comment
    By TheKedge in forum Qt Programming
    Replies: 1
    Last Post: 13th July 2006, 13:29
  5. Using QString in C function ...
    By Godlike in forum Newbie
    Replies: 10
    Last Post: 8th April 2006, 17:01

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
  •  
Qt is a trademark of The Qt Company.