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. Qpainter always print behind label
Forum Updated to NodeBB v4.3 + New Features

Qpainter always print behind label

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 2.4k Views 1 Watching
  • 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.
  • T Offline
    T Offline
    TobbY
    wrote on last edited by
    #1

    I have several labels on my screen(mainwindow.ui) And I need to draw on them. Unfortunately "Qpainter" just draws behind labels.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DenisKormalev
      wrote on last edited by
      #2

      Looks like you paint on widget that contains these labels. And labels' paintEvents are called after your widget paintEvent.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        TobbY
        wrote on last edited by
        #3

        how can i do that?? sorry i cant understand

        1 Reply Last reply
        0
        • G Offline
          G Offline
          giesbert
          wrote on last edited by
          #4

          Each widget (also a QLabel) has a background that is drawn onto the parent (e.g. your main window). You can reimplement each widgets paintEvent in a subclass and do your own painting there. If you overwrite the paintEvent of the main windwd, you draw behind each child, so behind the labels.

          If you want to change the labels, make a subclass of QLabel and use that instead of QLabel. Overwrite paintEvent in your QLabel subclass and draw there.

          If you want some main window image behind all labels, you could also make the labels transparent.

          Nokia Certified Qt Specialist.
          Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

          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