Results 1 to 5 of 5

Thread: How to build Qstring from char or string?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Sep 2010
    Posts
    654
    Thanks
    56
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to build Qstring from char or string?

    I want to use strings at Qmessagebox.
    Exists a function at QmessageBox to convert string to Qstring (that is the parameter waited by Qmessabox) ?
    I dont want to write no include if it is not neccesary.
    Thanks Kabanek & Zlatomir

  2. #2
    Join Date
    May 2010
    Location
    Romania
    Posts
    1,021
    Thanks
    62
    Thanked 260 Times in 246 Posts
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: How to build Qstring from char or string?

    You don't have to include anything, both the methods i suggested are in the QString (static members of QString), if you didn't notice, in my previous post the functions names are links to documentation.

    You can use it like this:
    Qt Code:
    1. std::string str = "Text";
    2. QString inText = QString::fromStdString(str);
    3. what_ever->setText(inText);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. How to convert QString to std::string or char*?
    By yangyunzhao in forum Qt Programming
    Replies: 26
    Last Post: 26th August 2009, 06:52
  2. Conversion Char Array to string
    By anafor2004 in forum Newbie
    Replies: 6
    Last Post: 6th May 2008, 14:35
  3. string to char*?
    By nass in forum General Programming
    Replies: 3
    Last Post: 2nd January 2007, 15:47
  4. problem converting string-char-int
    By mickey in forum General Programming
    Replies: 1
    Last Post: 9th December 2006, 23:43
  5. How to get size (length, width ....) of string or char
    By Krishnacins in forum Qt Programming
    Replies: 1
    Last Post: 20th March 2006, 09:55

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.