Display album covers in a grid



  • Hello guys,
    i am writing a music player and i need to create some pane where i can add music artists and generate album arts. Display should be image and text under the image.
    Image should be resizable(i can deal with that). Problem is that i cant find a containder that can for example get only 2 entries and still keep the predefined size.
    So far i found one kinda solution: used QListWidget in Icon mode. This is almost exactly what i need. Thing is that no matter how much entries are in the container,
    size of cover must be the same and also column count must be depending on the main window resize. So far the QListWidget works but i had different problem.
    When i am resizing the image (inserted as a Pixmap) the image goes below(or over) the text. I need the text to be below the image no matter the image size.
    So, bottom line, is there any way to do it with QListView or i need to use something like QGraphicsView (that i am too dumb to implement, cant understand anything).
    If i need to use GraphicsView can you show me example code?
    P.S. App is written in python. I have no idea how c++ even look so spare my soul and python me :D


  • Qt Champions 2017

    Hi
    Funny i say the same about python :)
    I cannot not handle the invisible { }

    Anyways, for the QListWidget in icon mode.

    Did you try the http://doc.qt.io/qt-5/qabstractitemview.html#iconSize-prop
    That way you can have them any size you want.

    else for GraphicsView , i would look at the 40.000 sample.
    http://doc.qt.io/qt-5/qtwidgets-graphicsview-chip-example.html
    (sorry c++) I dont know any where to get pyt samples from.



  • @mrjj icon size makes icon grow and hide the text


  • Qt Champions 2017

    @fixxxer
    Hmm. It did not hide text for me. Just made icons bigger.
    I will have a look in the evening.



  • In QML is incredibly easy to do, using QWidgets you probably want a QTableView with a custom QStyledItemDelegate with a reimplemented paint() and sizeHint() that handles the design. You can use a proxy model to split your list of icons into multiple columns.

    I have 0 idea of how to write in python so I won't even try post a code draft


Log in to reply
 

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