Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can i change the mouse pointer , when mouse over text with QStyledItemDelegate
Forum Updated to NodeBB v4.3 + New Features

How can i change the mouse pointer , when mouse over text with QStyledItemDelegate

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 1.9k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    umen242
    wrote on last edited by
    #1

    how can i change the mouse icon when mouse is over the text in item delegate ?
    i have this part but i can't find any example to change the mouse pointer . what im missing ?

    @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);
    }
    }
    }
    @

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved