Results 1 to 4 of 4

Thread: How can we edit the QListWidgets items and send the values back?

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

    Default How can we edit the QListWidgets items and send the values back?

    Hello everyone,

    I am new to Qt programming. I was working on a application where I am supposed to read the configuration paramenters from a server and the I am supposed to edit those values and send it back.

    In the first step I did coding on eclipse, such that when I run my program I get the configuration parameters from the server. the communication takes place through TCP connection.

    Now in the second step, I supposed to develop a GUI application using Qt, where I can see all the values on the window when I run the program. So far I am able to get the values on window. I did this program using QListWidget addItem, now in the next step I have to make the values editable. these values are coming from the server, so have to edit them and send back to the server.

    Can anyone help with this issue? I was trying to add the editItem and I have even tried using the setFlags, but nothing is working.

    thank you in advance.

  2. #2
    Join Date
    Jan 2011
    Posts
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How can we edit the QListWidgets items and send the values back?

    i thought you'd better use qlistwidgetitem's subclass as item in your widget, you should override data, setFlags, setData methods for showing data, editable data and store data. after that, you must use setItemWidget method to add your item in widget for you operate data.




    -- sory about bad english.

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

    Post Re: How can we edit the QListWidgets items and send the values back?

    Thank you for your reply... I tried with qlistwidgetitem but then I was unable to get the data..


    if (retVal == SOAP_OK) {
    // loop over all configurationKeys

    QListWidget *list1 = w.findChild<QListWidget *>("keyWidget");
    //QListWidget *list2 = w.findChild<QListWidget *>("valueWidget");
    QListWidgetItem *list2 = new QListWidgetItem("valueWidget");


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

    std::vector<cp__KeyValue *>::iterator it;
    for (it = getConfResponse->configurationKey.begin(); it != getConfResponse->configurationKey.end(); ++it) {

    //std::cout << "key is" << (*it)->key;


    list1->addItem(QString::fromStdString((*it)->key));
    //list2->addItem(QString::fromStdString(*(*it)->value).toStdString().c_str());


    //list2->addItem(QString::fromStdString(*(*it)->value));

    // BOOST_LOG(lg) << "Value :" << (*((*it)->value) != NULL : *((*it)->value) "not defined");
    if((*it)->value !=NULL)
    {
    BOOST_LOG(lg) << " Key :: " << (*it)->key << " Value :: " << (*(*it)->value);
    cout << " Key :: " << (*it)->key << " Value :: " << (*(*it)->value);

    //list2->addItem(QString::fromStdString(*(*it)->value));
    //list2->setText(QString::fromStdString(*(*it)->value));
    list2->setData(Qt:isplayRole, QString::fromStdString(*(*it)->value) );


    }

    else
    {

    BOOST_LOG(lg) << " Key :: " << (*it)->key << " Value :: " << (*it)->value;
    cout << " Key :: " << (*it)->key << " Value :: " << (*it)->value;
    //list2->addItem("0");

    }



    As we see in the code, when I try to use qlistwidgetitem I am getting empty message on the output

  4. #4
    Join Date
    Jan 2016
    Posts
    1
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: How can we edit the QListWidgets items and send the values back?

    it means that you have read data from severs in Qt application and you saw them, however you can't send your data to server?

Similar Threads

  1. Replies: 1
    Last Post: 1st November 2014, 13:42
  2. Replies: 9
    Last Post: 10th October 2012, 23:55
  3. Bring To Front Send To Back, where's the inbetween?
    By InterFiction in forum Newbie
    Replies: 1
    Last Post: 25th November 2011, 00:54
  4. Thread started from main does send signal back.
    By edxxgardo in forum Qt Programming
    Replies: 3
    Last Post: 20th July 2011, 15:36
  5. how can i edit pixel values
    By Askar in forum Qt Programming
    Replies: 1
    Last Post: 4th March 2010, 05:09

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.