Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to paint the QLabel own within of paintEvent() in a subclass of QLabel before to start my custom painting actions?

How to paint the QLabel own within of paintEvent() in a subclass of QLabel before to start my custom painting actions?

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 1.7k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    isaacEnrique
    wrote on last edited by
    #1

    Greetings .

    I am creating an application that displays an image along with other widgets. To display the image use one QScrollArea and a custom subclass of QLabel .

    In my subclass of QLabel I put the image (a QPixmap), but I also want to can highlight (draw) on QPixmap some figures (mainly rectangles representing the regions of interest).

    For these reasons I am reimplementing the QWidget::paintEvent (QPaintEvent* event) function. The part of the function code that draws rectangles is already written, however I do not know how to (within the QWidget::paintEvent() and before I start drawing the rectangles) , draw the QLabel own (so that QPixmap is painted). Obviously, I been unable to paint the QLabel own, what I get in my application is an empty QScrollArea.

    I do not know if there is a way (a function) to within QWidget::paintEvent() in a custom widget, the widget that is the parent class (in my case QLabel), is painted in the conventional manner and then proceed to the actions custom painted.

    Personally, I like not having to paint the QLabel own in "low level" if it fits the term (ie, as shown in paintEvent() of the QLabel class) before I can make my own painting actions.

    In short, the problem is that expressed in the title of this post:
    How to paint the QLabel own within of paintEvent() in a subclass of QLabel before to start painting my custom actions?

    Thanks in advance for any help and/or suggestions.

    Isaac Pérez
    Programming is understanding.

    1 Reply Last reply
    0
    • P Offline
      P Offline
      prady_80
      wrote on last edited by
      #2

      Why don't you make a custom widget containing a QLabel and in its paintEvent paint the QLabel highlight whichever area you want to?

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved