QListView IconMode - content problem



  • Hey guys,

    I have created a QListView and gave it the following settings:

    _listView = new QListView;
    _listView->setViewMode(QListView::IconMode);
    _listView->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
    _listView->setFlow(QListView::LeftToRight);

    Then i created a new QStandardItemModel and set the ListView Model to the new one.
    After this i wanted to test it with this:

    for(int i = 0; i < 10; i++)
    {
    model->appendRow(new QStandardItem(QIcon("images/no.jpg"), "SomeTestText"));
    }

    Here is my result:

    0_1531296550296_968b927c-e50d-48a9-9fd7-3c34bb89fde1-image.png

    now my question:

    Why isn't it filling the grid until the end ?
    Which setting am i missing here ?

    Thanks for reading so far.


  • Qt Champions 2017

    Hi
    try to add
    ui->theview->setResizeMode(QListView::Adjust);



  • Perfect, Thanks!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.