Add widget right aligned to a QTableWidget cell
-
@JonB said in Add widget right aligned to a QTableWidget cell:
Beware that this topic is not about replacing
setCellWidget(), the one aboutsetCellWidget()is still open.this is one hell of a lot of code to add for a delegate approach if setCellWidget() would have done the job?
setCellWidget()is just awful when you have a chance of using a delegate instead. Since I discovered that I can use a delegate instead, having asetCellWidgethas become very unsettling for me.@hbatalha
Thanks, I did wonder whether it was a different topic, but didn't try to go find it.Your sentiments must warm the cockles of @VRonin's heart ;-) But for those of us who value writing as little code as possble when there is built-in stuff it's not such good news. I do respect why delegates are a better choice, shame there is so much code to write.
@VRonin should "publish" a library/class,
QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want fromsetCellWidgetbut in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...] -
@hbatalha
Thanks, I did wonder whether it was a different topic, but didn't try to go find it.Your sentiments must warm the cockles of @VRonin's heart ;-) But for those of us who value writing as little code as possble when there is built-in stuff it's not such good news. I do respect why delegates are a better choice, shame there is so much code to write.
@VRonin should "publish" a library/class,
QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want fromsetCellWidgetbut in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...]@JonB said in Add widget right aligned to a QTableWidget cell:
Also, he should try to keep it down to, say, 10 lines...
ahahah!
should "publish" a library/class, QStyledItemWidgetDelegate
Already on my TODO list
-
@hbatalha
Thanks, I did wonder whether it was a different topic, but didn't try to go find it.Your sentiments must warm the cockles of @VRonin's heart ;-) But for those of us who value writing as little code as possble when there is built-in stuff it's not such good news. I do respect why delegates are a better choice, shame there is so much code to write.
@VRonin should "publish" a library/class,
QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want fromsetCellWidgetbut in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...]@JonB said in Add widget right aligned to a QTableWidget cell:
@VRonin should "publish" a library/class, QStyledItemWidgetDelegate, perhaps based on the code of his referred to in his last post, which does everything one might want from setCellWidget but in a delegate-y way, for everyone to use :) [Also, he should try to keep it down to, say, 10 lines...]
I was about to say that. Maybe propose the library to the Qt team to add to the official release(if that's how it is done)
-
@JonB said in Add widget right aligned to a QTableWidget cell:
Also, he should try to keep it down to, say, 10 lines...
ahahah!
should "publish" a library/class, QStyledItemWidgetDelegate
Already on my TODO list
-
@VRonin I have a simple question: is it possible to use
setItemDelegateForRowandsetItemDelegateForRowat the same view(same row)?@hbatalha said in Add widget right aligned to a QTableWidget cell:
@VRonin I have a simple question: is it possible to use
setItemDelegateForRowandsetItemDelegateForRowat the same view(same row)?I assume you mean
setItemDelegateForRowandsetItemDelegateForColumn.
from https://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForRowNote: If a delegate has been assigned to both a row and a column, the row delegate will take precedence and manage the intersecting cell index.
-
@hbatalha said in Add widget right aligned to a QTableWidget cell:
@VRonin I have a simple question: is it possible to use
setItemDelegateForRowandsetItemDelegateForRowat the same view(same row)?I assume you mean
setItemDelegateForRowandsetItemDelegateForColumn.
from https://doc.qt.io/qt-5/qabstractitemview.html#setItemDelegateForRowNote: If a delegate has been assigned to both a row and a column, the row delegate will take precedence and manage the intersecting cell index.