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)
    	{
    		QScrollBar::paintEvent(event);
    
    		QPainter p(this);
    		QStyleOptionSlider opt;
    		initStyleOption(&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,"||  ");
    		p.drawRect(handleRect);
    }
    

    http://i.stack.imgur.com/Acg62.png --> 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 !!!!

    Thanks
    Praveen


  • Lifetime Qt Champion

    Hi,

    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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.