마우스가 항목 위임의 텍스트 위에있을 때 마우스 아이콘을 어떻게 변경합니까? 이 부분이 있지만 마우스 포인터를 변경하는 예제를 찾을 수 없습니다.QStyledItemDelegate로 마우스를 가져 가면 마우스 포인터를 어떻게 바꿀 수 있습니까?
무엇이 누락 되었습니까?
void ListItemDelegate::paint(QPainter *painter, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
if (index.isValid())
{
int j = index.column();
if(j==4)
{
QString headerText_DisplayRole = index.data(Qt::DisplayRole).toString() ;
QApplication::style()->drawPrimitive(QStyle::PE_PanelItemViewItem, &option, painter);
QFont font = QApplication::font();
QRect headerRect = option.rect;
font.setBold(true);
font.setUnderline(true);
painter->setFont(font);
painter->setPen(QPen(option.palette.brush(QPalette::Text), 0));
const bool isSelected = option.state & QStyle::State_Selected;
if (isSelected)
painter->setPen(QPen(option.palette.brush(QPalette::HighlightedText), 0));
else
painter->setPen(QPen(option.palette.brush(QPalette::Text), 0));
painter->save();
painter->drawText(headerRect,headerText_DisplayRole);
painter->restore();
bool hover = false;
if (option.state & QStyle::State_MouseOver)
{
hover = true;
}
if(hover)
{
// THIS part i missing , how detect when mouse is over the text
// and if its over how to change the icon of the mouse?
}
}
else
{
QStyledItemDelegate::paint(painter, option, index);
}
}
}
감사합니다. 감사합니다 !!!! 블로그 게시물은 검색 2 일 후에 나를 구해줬습니다. – user63898