Results 1 to 4 of 4

Thread: QListwidget with checkbox compare sql table

  1. #1
    Join Date
    Feb 2010
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Question QListwidget with checkbox compare sql table

    Dear all,

    Any one have idea about how to compare the listwidet data with Database table with each row?

  2. #2
    Join Date
    Feb 2010
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Question Re: QListwidget with checkbox compare sql table

    Dear All

    Here is my snippet code
    can any one help me how to change the value in the DB table once we
    change the check box in list widget

    i have some list of data in listwidget.
    ii chance second check box enable & three checkbox Disable

    after i am calling this below function ?

    Qt Code:
    1. void FC::Config()
    2. {
    3. messageBox = new QMessageBox(this);
    4. if (QMessageBox::Ok == messageBox->question(this, "QDelete", "Config update?",
    5. QMessageBox::Ok | QMessageBox::Cancel))
    6. {
    7. TInt NCounts = ui.listWidget->count();
    8. TBuf<100> CCounts;
    9. CCounts.AppendNum(NCounts);
    10. int i;
    11. int j =1;
    12.  
    13.  
    14. for(i=0; i<NCounts; i++)
    15. {
    16.  
    17. if(ui.listWidget->item(i)->checkState() == Qt::Checked)
    18. {
    19. bool ret;
    20. QSqlQuery query;
    21.  
    22. ret = query.prepare(QString("UPDATE Table SET Enable = :Enable, Disable = :Disable where id = %1").arg(j));
    23. if(ret)
    24. {
    25. //query.bindValue(":Enable", );
    26. //query.bindValue(":Disable", );
    27. ret = query.exec();
    28.  
    29. }
    30. }
    31. else
    32. {
    33. QSqlQuery query;
    34. bool ret;
    35. ret = query.prepare(QString("UPDATE Table SET Enable = :Enable, Disable = :Disable where id = %1").arg(j));
    36. if(ret)
    37. {
    38.  
    39. //query.bindValue(":Enable", );
    40. //query.bindValue(":Disable", );
    41. ret = query.exec();
    42.  
    43. }
    44. }
    45. j++;
    46. }
    47. }
    48. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by damodharan; 28th May 2010 at 17:09.

  3. #3
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QListwidget with checkbox compare sql table

    can any one help me how to change the value in the DB table once we
    change the check box in list widget
    You change the data by executing an SQL update (or insert or delete)... but clearly you already know that.

    You need to explain the problem. What exactly happens when you uncomment and complete the bindValue() calls? Why is that not what you expected? What have you tried to overcome whatever the problem is?

    Other observations:
    • A table named "Table" is likely to be a problem for many RDBMSs
    • With a bit of re-arrangement you probably only need to prepare the query once
    • It is really poor etiquette to create a second thread to advertise another; doubly so when the original request is barely 12 hours old.

  4. #4
    Join Date
    Feb 2010
    Posts
    23
    Qt products
    Qt3 Qt4
    Platforms
    Windows Symbian S60

    Thumbs up Re: QListwidget with checkbox compare sql table

    thx for all,
    problem sloved

Similar Threads

  1. Replies: 1
    Last Post: 19th May 2010, 15:10
  2. How do compare the two icons
    By addu in forum Qt Programming
    Replies: 1
    Last Post: 10th July 2009, 16:19
  3. How to Compare Characters ASCII value?
    By merry in forum Qt Programming
    Replies: 5
    Last Post: 14th July 2008, 12:05
  4. do we can't compare QIcon or QPixmap????
    By sudheer in forum Qt Programming
    Replies: 2
    Last Post: 13th May 2008, 14:53
  5. Compare
    By merry in forum Qt Programming
    Replies: 1
    Last Post: 14th March 2007, 15:03

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.