문제

I would like to make a list of checkboxes for my programm, so that the users are be able to check/uncheck a number of different flags. However, I would like to make it behave like a QComboBox: to be folded most of the time, but to open itself when clicked.

What is the best way to add such functionality (e.g. derive a custom class from QComboBox, or do something with a QListView)? Thank you.

도움이 되었습니까?

해결책

There is a solution for it on the Qt forum:

http://qt-project.org/forums/viewthread/7740

It recommends the usage of a custom model/view, based on the tutorial 2_formatting in the examples folder.

다른 팁

Create your own QWidget that has a QCheckBox and the QComboBox.

Make signals and slot connections between the checkbox and the combobox.

Add your custom widget to the QListWidget using QListWidget::setItemWidget..

Using this you can add custom widgets to your QListWidget.

Hope that helps.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top