Important: Please read the Qt Code of Conduct -

Generate hover/Pressed/Released on Painter

  • Hi all,

    I have post one Issue that is resolved regarding Adding " || " on top scrollBar in left and right most that was done using QPainter.

    void paintEvent(QPaintEvent* event)
    		QPainter p(this);
    		QStyleOptionSlider opt;
    		opt.subControls = QStyle::SC_All;
    		QRect handleRect = this->style()->subControlRect(QStyle::CC_ScrollBar, &opt, QStyle::SC_ScrollBarSlider, this);
    		p.drawText(handleRect, Qt::AlignLeft,"  ||");
    		p.drawText(handleRect, Qt::AlignRight,"||  ");
 --> This is the reference Image you can see on Top Scroll I am able to create " || " on both end .

    Now the requirement is to generate & catch hover/pressed/released event's on leftmost as well rightmost on top of the line Drawn.

    So need a suggestion Thanks for your support !!!!


  • Lifetime Qt Champion


    AFAIK, you can do it using the corresponding mousePress/mouseRelease method but you'll have to the math yourself to determine if your mouse is over the regions of interest.

Log in to reply