Results 1 to 14 of 14

Thread: toStdString is returning an empty string !!!!

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question toStdString is returning an empty string !!!!

    Hi,

    Often, but not each time, "toStdString" is converting the string into an empty string !! It is completely random and do not know how to solve this problem ?

    do you have any idea ?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: toStdString is returning an empty string !!!!

    Did you make sure the input string is not empty in the first place? if so how?
    Post your code.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: toStdString is returning an empty string !!!!

    Yes, I'm in the debugger and the debugger show me the content of my string... everything sounds fine !!!
    Here is the code... so simple !!!

    string file = _currentFilePath.toStdString();

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: toStdString is returning an empty string !!!!

    can you show the following several lines too?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Oct 2010
    Posts
    95
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: toStdString is returning an empty string !!!!

    Thanks,

    I have this problem since several months !

    Here is the complete method :

    Qt Code:
    1. void psMainWindow::on_Menu_Save()
    2. {
    3. if (_currentFilePath.length() < 1)
    4. {
    5. on_Menu_SaveAs();
    6. return;
    7. }
    8.  
    9. UpdatePanelWidget::Start();
    10.  
    11. pureGraph::IE::Exporter exporter;
    12. string file = _currentFilePath.toStdString();
    13. exporter.Export(GlobalContext::Scene, file);
    14.  
    15. UpdatePanelWidget::Stop();
    16. }
    To copy to clipboard, switch view to plain text mode 

  6. #6
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: toStdString is returning an empty string !!!!

    and you say that when you stand on line 13 in the debugger, '_currentFilePath' has a valid string in it, and 'file' is an empty string?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

Similar Threads

  1. QLineEdit empty string
    By zgulser in forum Newbie
    Replies: 4
    Last Post: 3rd August 2010, 14:18
  2. QString::toStdString in PyQt Question
    By di_zou in forum Newbie
    Replies: 1
    Last Post: 2nd November 2009, 20:09
  3. QSplitter::saveState returns empty string
    By miraks in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2008, 21:30
  4. returning a string
    By mickey in forum General Programming
    Replies: 2
    Last Post: 3rd February 2008, 19:41
  5. QString .toStdString heap bug
    By bpetty in forum Qt Programming
    Replies: 1
    Last Post: 3rd October 2006, 17:10

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.