
Originally Posted by
tbscope
Then the documentation is not clear.
Check the source code of QTableView.
the "QTableView::horizontalOffset()" return "QHeaderView::Offset()", I think I need another thing!
I read Qt sorce code more and I found in "qcommonstyle.cpp":
{
...
case CE_ItemViewItem:
...
QRect textRect
= subElementRect
(SE_ItemViewItemText, vopt, widget
);
...
// draw the text
...
d->viewItemDrawText(p, vopt, textRect);
...
}
void QCommonStyle::drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *widget) const
{
...
case CE_ItemViewItem:
...
QRect textRect = subElementRect(SE_ItemViewItemText, vopt, widget);
...
// draw the text
...
d->viewItemDrawText(p, vopt, textRect);
...
}
To copy to clipboard, switch view to plain text mode
I try "subElementRect" (for item in first column) but:
subElementTextRect
= tableStyle
->subElementRect
(QStyle::SE_ItemViewItemText ,
&option
);
int textLeft=subElementTextRect .x(); //textLeft=0 <first row>
subElementFocusRectangle
= tableStyle
->subElementRect
(QStyle::SE_ItemViewItemFocusRect,
&option
);
int focusLeft=subElementFocusRectangle.x();//focusLeft=1 <first row>
subElementTextRect = tableStyle->subElementRect(QStyle::SE_ItemViewItemText , &option);
int textLeft=subElementTextRect .x(); //textLeft=0 <first row>
subElementFocusRectangle = tableStyle->subElementRect(QStyle::SE_ItemViewItemFocusRect, &option);
int focusLeft=subElementFocusRectangle.x();//focusLeft=1 <first row>
To copy to clipboard, switch view to plain text mode
textLeft is less than focusLeft!!!
We know textLeft should be bigger than focusLeft because focus rectangle doesn't cross text. what is wrong with above code?
Bookmarks