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. Adding some path to a QListView
Forum Updated to NodeBB v4.3 + New Features

Adding some path to a QListView

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 3.0k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    saidiahd
    wrote on last edited by
    #1

    how to add new element to a QListView ? i I tried with :

    @QString path;
    path = QFileDialog::getOpenFileName(this,
    tr("Choose a file to open"),
    QString(),
    tr("Images (*.png *.jpg)")) ;

    new QListViewItem(ui->listView, path);@
    but its not work.

    "Learn from yesterday, live for today, hope for tomorrow." - Albert Einstein -

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #2

      bq. new QListViewItem(ui->listView, path);

      Initialised to ?

      And you want to use QListView ,not "QListWidget":http://doc.qt.nokia.com/latest/qlistwidget.html ?


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        saidiahd
        wrote on last edited by
        #3

        what do you mean by initialized to ? plz more details
        yes i want use QListView

        "Learn from yesterday, live for today, hope for tomorrow." - Albert Einstein -

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rahul Das
          wrote on last edited by
          #4

          Am sorry if am not clear.
          I think , there is a problem with line 7. Initialization issue.

          EDIT : you can have a look at "this":http://www.qtforum.org/article/27479/how-to-insert-new-items-into-a-qlistview.html .Hope its useful to you.


          Declaration of (Platform) independence.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            If you want to use QList_View_, then you are using it with a model, a QAIM subclass. If you want to add something to the displayed list, you have to add that piece of data to the model. The view will then display it. You are not telling us what type of model you are using, so it is hard to tell you how to do this.

            In your small code sample, you are trying to do something that looks more like how you would work with QListWidget. That will not work. Perhaps your model is a QStandardItemModel? In that case, you can add a new item to this model with a syntax that looks a bit like what you are trying to do.

            1 Reply Last reply
            0

            • Login

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