PDA

View Full Version : Highlight the text in QWidget on mouseMoveEvent



mythili
22nd April 2013, 07:47
I want to hightlight the text in QWidget i..e, text in the scribble area on mouseMoveEvent which is same as highlight done in word document. Color should be brushed under the word.

rawfool
22nd April 2013, 07:57
Are you trying to use QLabel or any text display widget ? Or Painter ?

mythili
22nd April 2013, 08:03
I am using the scribble example. I want to highlight the text in the scribble area

ChrisW67
22nd April 2013, 08:11
There is no "text" in the "scribble area", it's just a bunch of pixels. If you want to draw a line under something that's already been drawn in the widget's client area then you want QPainter::drawLine(). If you want to draw underlined text in the widget's client area then you use QPainter::drawText() with a QFont that has underlining turned on.

mythili
22nd April 2013, 08:49
Thank u. I have drawn something in the scribble area. I want to highlight the selected area on mouseMoveEvent. Can u help me some lines of code.

Santosh Reddy
22nd April 2013, 18:50
If you want selection (and other graphical interactions) you better should look at Diagram Scene Example (http://qt-project.org/doc/qt-4.8/graphicsview-diagramscene.html). Scribble example will not help you.

Bottom line is that you need to use QGraphicsScene and QGraphicsView.

BalaQT
24th April 2013, 08:43
If you just want to highlight the entire image, try QImage::invertPixels()

But if you want to work gui interactions (try QGraphicsScene as Santhosh told)


Color should be brushed under the word
If you are developing text editor, Then you check QTextEdit. This will take care of highlighting the word selection.

Bala