Results 1 to 15 of 15

Thread: qstring assignment crashes the program

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jun 2014
    Posts
    48
    Thanks
    6
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: qstring assignment crashes the program

    thanks a lot you solved my problem i did llike this
    Qt Code:
    1. QString name = qry.value(0).toString();
    2. this->name = name;
    3.  
    4. int n = qry.value(1).toInt();
    5. this->stock = n;
    6.  
    7. float r = qry.value(2).toInt();
    8. this->rate = r;
    9.  
    10. int number = qry.value(3).toInt();
    11. this->number = number;
    To copy to clipboard, switch view to plain text mode 
    but i don't get the point how is it happening, Please explain.

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: qstring assignment crashes the program

    It makes no sense to me.
    By the way.
    1. You are not guaranteed that a SELECT * query will return the record columns in the specified order. Either construct the query by explicitly entering the column names or retrieve the values later via QSqlRecord and field names.

    2. There should be no toFloat() on line number 7 ?

Similar Threads

  1. Crash on QString assignment
    By ce_nort in forum Newbie
    Replies: 5
    Last Post: 25th March 2016, 16:08
  2. QString exception while executing assignment operation
    By Giox79 in forum Qt Programming
    Replies: 1
    Last Post: 2nd March 2015, 12:30
  3. Replies: 6
    Last Post: 29th December 2011, 18:37
  4. QString assignment
    By valgaba in forum Qt Programming
    Replies: 4
    Last Post: 25th April 2010, 17:31
  5. QMap <int, QGuardedPtr<Employee> > Crashes on Assignment ???
    By sunil.thaha in forum Qt Programming
    Replies: 2
    Last Post: 16th March 2006, 07:09

Tags for this Thread

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.