Page 2 of 2 FirstFirst 12
Results 21 to 22 of 22

Thread: Issue using QString

  1. #21
    Join Date
    Jun 2017
    Posts
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Issue using QString

    Thanks for this! I thought I was going mad!

    Quote Originally Posted by South African View Post
    I have found the solution to this.

    If you downloaded a pre-built version of Qt, and are using VS2010, you will get this problem. Rebuild QT with VS2010 and it fixes it (I tested it).

    So, it was toStdString causing the error, because of mismatches between VS2008 and VS2010 code generation for STL/Qt. It was not some other user code before, causing it to manifest there.

    I hope you get your problem fixed

    Keep well,
    David

  2. #22
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,348
    Qt products
    Qt5
    Platforms
    Windows
    Thanks
    318
    Thanked 872 Times in 859 Posts

    Default Re: Issue using QString

    The technical reason is that in VS2008 and VS2010, new applications used the compiler flag "Treat wchar_t as a built in type" with the value "No" ("/Zc:wchar_t-"), whereas the Qt distribution was built with the opposite setting ("/Zc:wchar_t"). The compiler didn't know anything was wrong, nor did the linker. It wasn't until runtime that crashes would occur.

    The workaround for VS2010 was to either rebuild the Qt binaries as suggested, or to change the project settings to reverse the flag. Changing the project settings also means that any other external libraries that use wchar_t also have to be built the same way.

    In current releases of Visual Studio (and Qt pre-built binaries), the default setting is now "Yes" ("/Zc:wchar_t") everywhere so everything is compatible.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 11th August 2011, 16:42
  2. Replies: 5
    Last Post: 13th May 2011, 01:02
  3. Replies: 4
    Last Post: 1st February 2010, 15:21
  4. QString formatting issue.
    By George Neil in forum Qt Programming
    Replies: 2
    Last Post: 22nd October 2009, 10:00
  5. Replies: 4
    Last Post: 31st January 2008, 21:44

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.