Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

[Solved] Quotes included when gets info from QListWidgetItem.



  • I add QStrigs to QListWidgetItem (custom) as follows:

    @

    QList<QString> CustomItem::listItemsAvailable = QList<QString>() << QString("One")
    << QString("Two")
    << QString("Three);
    @

    When I try to get the selected item, as follows:

    @
    QString text = currentItem()->text();
    qDebug () << text;
    @

    I returns the selected List Item, but with quotes, so, qDebug() writes: "One", for example. With qoutes.

    How it comes?

    Thank you.


  • Moderators

    Your string does not contain quotes.

    QDebug prints quotes around all QStrings.

    @
    QString qstr("Hello");
    qDebug() << "Hello" << qstr;
    @
    gives

    @
    Hello "Hello"
    @



  • Oh boy, thank you, and sorry for that.


  • Moderators

    You're welcome, and no need to be sorry! We all learn by asking questions. :)


Log in to reply