Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Insert one text to QListView
Forum Updated to NodeBB v4.3 + New Features

Insert one text to QListView

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 2 Posters 1.7k 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 Extensions
      • Unsolved