@hskoglund I already have an underlying data store and I'm using a subclass of QAbstractTableModel to bridge it into a Qt GUI.
Making two in-memory copies of that data store and then jerry-rigging View-like synchronization between the actual data and two widget-specific data stores (plus all the requisite automated testing to make sure it works reliably) seems like the exact opposite of what I want.
I have created a class customDelegate (inherits QItemDelegate) in my Qt applicatrion and i created setEditor() function.But the delegate is not visible in the QTableView , untill i click on the row.
How to fix the issue?
How did you implement the paint() in your custom delegate ? As you are adding different widget in each cell, you need to paint a fake widget (QPushButton) using QApplication::style()->drawControl(QStyle::CE_PushButton, &btn,painter); where btn is QStyleOptionButton, then in createEditor() you create an instance of QPushButton.
I think I take your meaning. As I geared up to subclass QAbstractItemView, it also became evident how niche my new class would be. Based on this, I decided to take your advice of composing a custom widget.
If anyone should want to subclass QAbstractItemView, this is a good article to get you started.
@Harb When I understood correctly a column of a QTableView which has a delegate assigned will automatically resize itself to the QItemDelegate::sizeHint() size. Therefore, I could return the required width of the column to display the full text in the cell, right?
My custom delegate uses a QComboBox. The combobox is populated with items of different length. Now, let's assume there is just one row in the table and the item in the cell with the custom delegate is the item in the combobox with the shortest width. Therefore, the column will be just wide enough to display that text. When the user then clicks on the cell and the combobox dropdown shows up the user will not be able to see entries in the combobox which are longer. Items in the combobox which are longer than the width of the column will be shorted and three dots will be inserted.
What I would like to do is using the QItemDelegate::sizeHint()to return the QComboBox::sizeHint() so the column will automatically be wide enough to display all items (because the QComboBox::sizeHint() returns the size so all items can be displayed.