Results 1 to 5 of 5

Thread: setText not working

  1. #1
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default setText not working

    What is wrong with this code:
    Qt Code:
    1. void CCustomerUpdateDialog::slotZipcodeChanged(int iIndex)
    2. {
    3. QSqlQuery retrieveCityNameQuery("SELECT * FROM kraj k WHERE k.POSTNA_STEVILKA="+m_pZipcode->currentText());
    4. QSqlError error=retrieveCityNameQuery.lastError();
    5. if(error.type()!=QSqlError::NoError)
    6. {
    7. qDebug() << retrieveCityNameQuery.lastError();
    8. } else
    9. {
    10. m_pCity->setText(retrieveCityNameQuery.value(1).toString());
    11. }
    12. };
    To copy to clipboard, switch view to plain text mode 

    I select a zip code of an city and in the QLineEdit should provide then after click the name of city with selected Zip Code. But, sql i generated ok (double check), QLineEdity still stays empty! Why?
    Qt 5.3 Opensource & Creator 3.1.2

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setText not working

    You forgot to invoke QSqlQuery::next().

  3. #3
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: setText not working

    LOL, f... amateur. Thanks man.
    Qt 5.3 Opensource & Creator 3.1.2

  4. #4
    Join Date
    Jan 2006
    Location
    Kerala
    Posts
    371
    Thanks
    76
    Thanked 37 Times in 32 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: setText not working

    Use Prepared Queries whenever possible.
    Or else you are giving chance for Sql Injection
    We can't solve problems by using the same kind of thinking we used when we created them

  5. #5
    Join Date
    Jan 2006
    Location
    Ljubljana
    Posts
    687
    Thanks
    111
    Thanked 4 Times in 4 Posts
    Qt products
    Qt5 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: setText not working

    Yes, I''need sql injection.
    Qt 5.3 Opensource & Creator 3.1.2

Similar Threads

  1. QPushButton setText problem
    By batileon in forum Qt Programming
    Replies: 3
    Last Post: 3rd December 2008, 04:02
  2. QResource Stopped Working
    By JPNaude in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 13:26
  3. QDevelop and CTags -> Not working
    By philwinder in forum Qt-based Software
    Replies: 13
    Last Post: 9th May 2008, 22:40
  4. Don't want QTextBrowser to look in working directory
    By magland in forum Qt Programming
    Replies: 1
    Last Post: 21st October 2007, 00:14
  5. GUI thread and Working thread comunication
    By FasTTo in forum Qt Programming
    Replies: 2
    Last Post: 13th September 2007, 16:31

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.