Results 1 to 7 of 7

Thread: Highlight the text in QWidget on mouseMoveEvent

  1. #1
    Join Date
    Mar 2013
    Posts
    43
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Highlight the text in QWidget on mouseMoveEvent

    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.

  2. #2
    Join Date
    Sep 2011
    Location
    Bangalore
    Posts
    254
    Thanks
    92
    Thanked 16 Times in 16 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Windows

    Default Re: Highlight the text in QWidget on mouseMoveEvent

    Are you trying to use QLabel or any text display widget ? Or Painter ?

  3. #3
    Join Date
    Mar 2013
    Posts
    43
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Highlight the text in QWidget on mouseMoveEvent

    I am using the scribble example. I want to highlight the text in the scribble area

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Highlight the text in QWidget on mouseMoveEvent

    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.

  5. #5
    Join Date
    Mar 2013
    Posts
    43
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Highlight the text in QWidget on mouseMoveEvent

    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.

  6. #6
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Highlight the text in QWidget on mouseMoveEvent

    If you want selection (and other graphical interactions) you better should look at Diagram Scene Example. Scribble example will not help you.

    Bottom line is that you need to use QGraphicsScene and QGraphicsView.
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  7. #7
    Join Date
    Aug 2009
    Location
    coimbatore,India
    Posts
    314
    Thanks
    37
    Thanked 47 Times in 43 Posts
    Qt products
    Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Highlight the text in QWidget on mouseMoveEvent

    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
    Last edited by BalaQT; 24th April 2013 at 08:43.

Similar Threads

  1. Highlight an item in QCombobox by text color
    By AlekseyK in forum Qt Programming
    Replies: 6
    Last Post: 18th March 2019, 21:31
  2. Replies: 1
    Last Post: 5th August 2008, 20:44
  3. Changing QPushButton text colour with mouseMoveEvent
    By Misenko in forum Qt Programming
    Replies: 1
    Last Post: 10th June 2008, 16:53
  4. Setting a highlight text color for QTableWidgetItem
    By Hiba in forum Qt Programming
    Replies: 6
    Last Post: 14th December 2007, 10:51
  5. Highlight text in list box
    By Sheetal in forum Qt Tools
    Replies: 7
    Last Post: 9th April 2007, 11:24

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.