QTableView placing widgets inside cells
-
Hello,
I want to place some multiple widgets(at least 2)(2 combo box or line edit) inside one column every row how can I accomplish that?
I have seen some examples with QStyledItemDelegate but I couldnt find with multiple widget examples.
I saw an exaple from https://stackoverflow.com/questions/51577711/qstyleditemdelegate-how-to-make-two-widgets-in-one-row, but I didnot understand how he did associate widgets with columns, for example,model->setData(index, widget->text(), Qt::DisplayRole);What if I do have more than one column with Qt::DisplayRole, and I understand with this method the widgets are visible only in edit mode is it true?.
Thank you for your time.
-
Hello,
I want to place some multiple widgets(at least 2)(2 combo box or line edit) inside one column every row how can I accomplish that?
I have seen some examples with QStyledItemDelegate but I couldnt find with multiple widget examples.
I saw an exaple from https://stackoverflow.com/questions/51577711/qstyleditemdelegate-how-to-make-two-widgets-in-one-row, but I didnot understand how he did associate widgets with columns, for example,model->setData(index, widget->text(), Qt::DisplayRole);What if I do have more than one column with Qt::DisplayRole, and I understand with this method the widgets are visible only in edit mode is it true?.
Thank you for your time.
@ikuris said in QTableView placing widgets inside cells:
What if I do have more than one column with Qt::DisplayRole
What exactly do you mean by this?
I would first try to re-evaluate what you are trying to achieve? You should not be storing more than one value in a cell (model index), and you ought not be needing these multiple widgets. And btw an editable combo can contain both values for the user to pick from and allow any value to be typed.