PDA

View Full Version : select a particular area



vishesh
28th February 2007, 17:04
how to select a particular area in qwidget using mouseevents

jpn
28th February 2007, 18:16
Here's a one approach:

press event:
- store the event position

move event:
- draw a rectangle from press point to move event position

release event:
- apply the selection
- invalidate press point

vishesh
28th February 2007, 19:14
How to draw a rectangle in application

jpn
28th February 2007, 19:54
Use QPainter. Here's an example from the docs (http://doc.trolltech.com/3.3/qpainter#details):


void SimpleExampleWidget::paintEvent()
{
QPainter paint( this );
paint.setPen( Qt::blue );
paint.drawText( rect(), AlignCenter, "The Text" );
}

Replace QPainter::drawText() with QPainter::drawRect()..

vishesh
28th February 2007, 21:44
thank you its working properly:)