ItemView (QListView)
-
Hi there I am trying to have my 3 customWidget shown to my list view but yet I have not found any solution.
I want By default when my dialog with list view is shown it should show all items having CustomWidget1 when mouse is hovered on any of those item it should show customWidget2 and when mouse hover is out it should come back showing customWidget1. and the third one is when item is doubleClick it should show customWidget3.
I tried doing this using itemdelegate createEditor() but dont know how to get mouse hover in my listview, I connected entered() signal but once item is set to my customWidget I am not getting entered() event at all.
Please help -
I am sorry, but the item views are really not suited for this use.
For this use, I'd recommend to just put your items/widgets in a grid layout, and put that on a QScrollArea. If you expect to have many items (>100 or so) in your view, another solution may be needed. -
Yes my view could be having more than 3k items. what other way could be best suited Andre?
-
Than, you simply cannot use widgets. You will have to use real delegates to do your rendering from scratch directly from the delegate. I don't know what you have in your widget, but if there are other widgets in there (buttons, checkboxes, or worse: even more complicated widgets), you have a real problem. You won't be able to replicate those properly on your own in a delegate.
Or, alternatively, you might want to look into using QML (1) for this. In QML, it is easier to create items that behave dynamically (change appearance and / or size on hover, have buttons, etc) than it is in the widget world, but that has limitations of its own.
-
Andre, thanx but unfortunately QML is not an option
I do have some three to four widgets like lineEdit combo and button, let me see if I can do something using delegate -
You are going to have a very hard time to get a delegate to work for such interactive widgets. Item views and using widgets for items just don't mix well. Creating 3000+ of your custom widgets x3 per state is never going to perform well. Note that you can use QML for only this item view. The rest of your application could still be widget based.
-
we discussed your suggestion with team and we are kind of getting agreed on this.
I will come back on this again when we need some help, Thank for help -
Please take note that there are trade-offs with all of the possible approaches. QML isn't perfect either, but it might be enough for you. I cannot make that judgement for you.