QTreeView inline edit alignment problem
-
@jronald
Which of the following are you asking about/not liking:- The line edit is not as wide as the
2018
(or2017
) column? - The line edit's content is left- not right-aligned?
- The line edit for the
2018
column appears in the2017
column (apparently)?
- The line edit is not as wide as the
-
@JonB said in QTableView inline edit alignment problem:
@jronald
Which of the following are you asking about/not liking:- The line edit is not as wide as the
2018
(or2017
) column?
For column "2018",
- the width of the edit is not as wide as the column
- the offset of the edit is not as expected, it should on the cell in column "2018", but it's in column "2017" now
- The line edit's content is left- not right-aligned?
right aligned
- The line edit for the
2018
column appears in the2017
column (apparently)?
Yes
- The line edit is not as wide as the
-
@jronald
Well let's start with: I have never seen the edit widget appear anywhere else than in its own column, certainly not in another column. So I suggest you start by discovering why this is for you (e.g. try a minimal case in a fresh application).Look at your table view's
itemDelegate()
. You can access the line edit in QAbstractItemDelegate::createEditor(), e.g. set it to align right or affect its width. You may have to derive your own class fromQStyledItemDelegate
and set the table view to use that. -
@jronald
It should not be hard at all, just aQTableView
with a 2 column model. If it is hard to reproduce then something is going on/others will not be able to repro. As I say, I have used it many times with no problems, and don't you think other people would report if every time they tried to edit from aQTableView
it went as badly wrong as this?Anyway, if it really does this (and I think you have something wrong in your code) I told you what you can do about it.