Results 1 to 8 of 8

Thread: How to save the edited data in QListwidgetitem using a push button

  1. #1
    Join Date
    Jan 2016
    Posts
    22
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default How to save the edited data in QListwidgetitem using a push button

    Hello Everyone,

    I am having a problem in saving the data obtained from Qlistwidgetitem. I am using a QListWidgetItem, where I am getting some data from the server on the window. Now I am able to edit the data whivch I got from the server. In the next step Ishould be able to save the data I have edited and send back to the server.

    Please can anyone help me with this situation.

    Thank you in advance

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to save the edited data in QListwidgetitem using a push button

    It is hard to tell what part of the task you need help with?

    Do you have a slot connected to the button?
    Does that slot have access to the QListWidget?

    Cheers,
    _

  3. The following user says thank you to anda_skoa for this useful post:

    Choti (11th January 2016)

  4. #3
    Join Date
    Jan 2016
    Posts
    22
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to save the edited data in QListwidgetitem using a push button

    edit.jpg


    Thank you for your reply. Yes I have a slot connected to the button. As shown in the picture that was the data I recieved from the server. Now I am supposed to edit the "values" and save them and send back using the pushbutton SEND. I am able to edit the values but I am confused how to save the edited data.

  5. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to save the edited data in QListwidgetitem using a push button

    I assume this is about the second list and the values are all integers?

    You can simply iterate over the list using QListWidget::count() and QListWidget::item() and for each item e.g. get the text with QListWidgetItem::text() and calling QString::toInt() to convert to integer.

    Cheers,
    _

  6. #5
    Join Date
    Jan 2016
    Posts
    22
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to save the edited data in QListwidgetitem using a push button

    The second list is a group of strings. Among all the values I am supposed to edit only two values which are non zero. Then I should save it and send back to the server.


    void MainWindow:n_pushButton_clicked()
    {
    QListWidgetItem *list2 = ui->valueWidget->currentItem();

    list2->setFlags(list2->flags()|Qt :: ItemIsEditable);

    }


    As shown in the code list2 is getting data from the server .

  7. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to save the edited data in QListwidgetitem using a push button

    So what actually do you need help with?

    This code makes the current item editable.

    Cheers,
    _

  8. #7
    Join Date
    Jan 2016
    Posts
    22
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: How to save the edited data in QListwidgetitem using a push button

    Now I want to save the edited value .

  9. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How to save the edited data in QListwidgetitem using a push button

    Well, get the value from the item (see comment #4) and save it.

    Cheers,
    _

  10. The following user says thank you to anda_skoa for this useful post:

    Choti (13th January 2016)

Similar Threads

  1. push button
    By arumita in forum Newbie
    Replies: 1
    Last Post: 3rd June 2014, 01:02
  2. Replies: 1
    Last Post: 11th March 2014, 15:44
  3. Get data from table view after item was edited?
    By schmimona in forum Qt Programming
    Replies: 7
    Last Post: 8th September 2011, 12:47
  4. Save mercurial push url?
    By realdarkman71 in forum Qt Tools
    Replies: 2
    Last Post: 21st November 2010, 18:54
  5. Replies: 4
    Last Post: 25th January 2010, 13:52

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.