Important: Please read the Qt Code of Conduct -

More vector question

  • I hope nobody is getting tired of me asking these C++ and NOT Qt questions.

    OK, I have QStringList retriving this, in () , from a function :

    HCI returnValue  (" address ", "", " name", "")

    using this code :

      QVector<QStringList> returnValue = futureWatcher_run.future().result();

    Now I like to post the "return" value to "listWidget" in single line .

    I can get individual item (QString) from the list

      QString string = futureWatcher_run.future().result().at(0).at(0);

    I can get individual item (QStringList) from the vector and use "addItems"

       QStringList  stringList  = futureWatcher_run.future().result().at(0); //.at(0);

    The "problem" - is there an easy / neat way to enter / show the items in listWidget on one / single entire QStringList line , not each individual item on separate line , when "addItems" is used ?

    I was going to use do/while and retrieve / add to item QString , not QStringList, but I am not sure if the would resolve the issue .

    For now each QString of the QStringList is being added on its own line in "listWidget" .

    This is not a "show stopper" , but I could use some help in figuring this out.
    Perhaps using widget with "append" method would be better solution ?


  • Moderators

    Do you mean something like this?

    ui->listWidget_2->addItem(stringList.join(" "));

  • @Chris-Kawa said in More vector question:

    ui->listWidget_2->addItem(stringList.join(" "));

    Perfect ...thanks


  • Moderators

    @AnneRanch It's unaligned and looks kinda messy. It would look a lot better if you used a QTreeWidget or QTableWidget instead and placed address and name in separate columns.

  • Lifetime Qt Champion

    @AnneRanch said in More vector question:

    I hope nobody is getting tired of me asking these C++ and NOT Qt question

    There is a dedicated forum for C++ questions:

Log in to reply