Solved Customize QListView or QListWidget
-
Hello, i am making a program, the purpose of which is to test students.
The approach that I came up with is - to use QListWidget for representing questions. But every question have some variants too. Is there way to represent one item in list like:
Here will be question?
- first variant
- second variant
- third variant
- fourth variant
where dots are radiobuttons.
Or i need to choose another approach for this task?P.S. I am new in Qt. Sorry if there is obvious answer.
-
@eukr Wouldn't http://doc.qt.io/qt-5/qbuttongroup.html be better?
-
Hmm, maybe buttons is better than radio, but the main question is, how to show string(question) and buttonbox(variants) in one item of QListWidget.
-
Sure, save the 4 variants in different roles (
Qt::UserRole + i
) usingsetData
and then reimplementQStyledItemDelegate::paint
to lay out the variants -
@VRonin Thank you! And for those who will face my problem - look here first! And than documentation about QStyledItemDelegate Class.
P.S. another good discussion - click