See from the left part picture, the child content is hided, I need adjust the column width to show out the child content.
So I want to know how to show the whole content of child without adjust the column width.
Attachment 13068
Printable View
See from the left part picture, the child content is hided, I need adjust the column width to show out the child content.
So I want to know how to show the whole content of child without adjust the column width.
Attachment 13068
Have you tried QHeaderView::setSectionResizeMode()?
Cheers,
_
Hi, thanks for your reply. I used the setSectionResizeMode() in the follow Attachment 13069way. The first column width will adjust automatically. But what I want is, the column width of the parent item not change, just change the child item column width. Like this picture show. The child content length is longer than the parent column width. How can I achieve this?
t->header()->setSectionResizeMode(QHeaderView::ResizeToContent s);
Ah, you don't want to change the width of a column, you want certain cells to span more than a column.
Might be possible with a custom delegate on the first column.
When it is handling a top level entry it would do normal drawing, when handling a sub item it would ignore the cell rectangle's width.
Cheers,
_
Hi, As your suggestion, I implement a delegate in follow way.
this solve my previous problem, but I meet another problem, when I adjust second column width it will hide the content of child item. how to solve this problem, see the attachment.Code:
{ if(index.parent().isValid()) { QStyleOptionViewItem myOption = option; myOption.rect.adjust(0,0,500,0); myOption.displayAlignment = Qt::AlignLeft | Qt::AlignVCenter; QApplication::style()->drawItemText ( painter, myOption.rect , myOption.displayAlignment, QApplication::palette(), true,text ); } else { QStyledItemDelegate::paint(painter, option, index); } }
Attachment 13071