[SOLVED] What widget is better to show images in a list?



  • So what i want is this

    !http://i.imgur.com/UDf4R.png(image)!

    What is the better widget on creating something like this? I am very familiar with listwidget and my friend has reached this point:
    !http://i.imgur.com/BmAcn.png(image2)!

    but i dont like every image to have a text under it.. so if i remove the text something ugly happens:
    !http://i.imgur.com/7Fu7z.png(image3)!

    there is a gray line under the images..

    So what must i use? qlistwidget, qlistview or what?
    And if it is qlistview, could you quide me just a little?



  • Can't see the pics.



  • Ah,I think you can try the QStackedLayout to implement this effect.



  • You can use a list view and a model.
    Just return the pixmap as Qt::DisplayRole, that should not put any text below it, right?



  • [quote author="Gerolf" date="1346400224"]You can use a list view and a model.
    Just return the pixmap as Qt::DisplayRole, that should not put any text below it, right?[/quote]

    i am a complete newbie to listview so i tried it..

    what i managed is this:

    @ QStandardItem* Item1 = new QStandardItem(QIcon(":/image1.png"), "Text1");
    QStandardItem* Item2 = new QStandardItem(QIcon(":/image2.png"), "Text2");
    QStandardItem* Item3 = new QStandardItem(QIcon(":/image3.png"), "Text3");
    QStandardItemModel* ListModel = new QStandardItemModel();
    ListModel->appendRow(Item1);
    ListModel->appendRow(Item2);
    ListModel->appendRow(Item3);

    ui->listView->setModel(ListModel);@
    

    1st i can't remove the "Text".. What should i do for this..
    and 2nd i don't want the items to be showen every row.. but as the screenshots at the 1st post.. it seems i can see only appendrow/column not something like additem..



  • [quote author="henryxuv" date="1346400067"]Ah,I think you can try the QStackedLayout to implement this effect.[/quote]

    No this isn't what i want.. Listview is what i want.. can anyone answer what i asked above?



  • Have you tried subclassing QAbstractItemModel or QAbstractListModel instead of using QStandardItemModel? Further: To have items fill from left to right and wrap, use setFlow and setWrapping, but that seems to be in place already considering your posted screenshots.



  • Well we ended up using listwidget! About the grey thing that appears, we found a "solution" , with this:

            @item->setSizeHint(QSize(width,height));@
    

    which height is smaller making the grey thing not appear!

    I took a screenshot to show it, in which i zoomed in one item ;)

    !http://i.imgur.com/X22B7.jpg(1)!

    Even the qt exampe Puzzle had and yet has this problem:
    !http://i.imgur.com/uPhTk.png(1)!


Log in to reply
 

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