Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
qtws26_logo

The Qt Event of the Year: Qt World Summit 2026

Save Your Spot >
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Insert one text to QListView
Qt 6.12 LTS is out! See what's new in the release blog

Insert one text to QListView

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    qwe3
    wrote on last edited by
    #1

    Hi,

    I have QListView, QStringListModel, QStringList and QTimer.

    When I would like to add one new text to QListView I have to add it to QStringList, set this list in a QStringListModel and set this listModel in QListView.

    model->setStringList(list);
        
    listView->setModel(model);
    

    It works, but... this is strange for me. Always I have to add all texts to QListView ( always I set model in QListView ). Maybe is a way, where I can add only one new text and still have textes, which I add before? Something like:

    listView->addText(newText);
    
    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      QStringListModel has (like every other QAbstractItemModel) the function https://doc.qt.io/qt-5/qstringlistmodel.html#insertRows and https://doc.qt.io/qt-5/qstringlistmodel.html#setData to insert rows and modify the data.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt
      • Unsolved