Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6008749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:52:07+00:00 2026-05-23T01:52:07+00:00

I am building a small GUI interface and I have a QLabel that draws

  • 0

I am building a small GUI interface and I have a QLabel that draws images from a directory onto itself by setting them as the pixmap. I want the user to be able to interactively click points on this pixmap and have a small green ‘x’ appear at the clicked locations. I have tried re-implementing the paintEvent method, but this is not the functionality I want at all. paintEvent is what gets called every time there is a reason to paint on the QLabel… whereas I want to leave the base drawing (the image) alone and simply place points on top of the already-drawn image. Eventually, I am going to want the user to be able to interactively track these points through a sequence of images, using third-party tracking algorithms. Thus, I need the capability of having the user move points around, remove points, add points, and modify them without needing to re-draw the image behind them. There are several tutorials online about simply drawing points, but they all involve re-implementing the paintEvent method and then connecting a mouseEvent to the paintEvent. I am trying to specifically avoid this. Any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T01:52:08+00:00Added an answer on May 23, 2026 at 1:52 am

    You actually do want to use a paintEvent() override. Even if you do want to only draw things over an image, the widget still needs to be able to redraw portions of the image if you remove or move things that are drawn over it and this happens in the paintEvent(). If you want to add things to the rendering, that’s where you have to do it too.

    Think of the paintEvent() as draw-the-entire-part-of-the-widget-that's-visible-Event(). If you are using a subclass of QLabel, then your override should call QLabel::paintEvent(e) and then your stuff.

    It sounds like you will be maintaining a list of points so your part of the paintEvent() should draw all of your points in the manner you require.

    Your mouse events should do something to your list of points (like add a point or move a point) and then call update() which will trigger a call to paintEvent() which will redraw the entire widget with the background image and your updated points. There should be no connecting of mouse events to paintEvent() or messing around with trying to track or handle mouse events inside paintEvent().

    The main thing to remember is that mouse events will modify your “model” and the paintEvent() will draw the entire model whenever it changes. Even if there was an abstraction/function that only required you to draw new things or things that changed, under the covers, lots of stuff still needs to be erased and redrawn.

    This can be optimized by making use of the region information in the event object passed into paintEvent() but this usually isn’t necessary.

    You can look at a somewhat similar example in an answer to another question that I provided although it may not be that different from other examples you’ve already seen. It isn’t in Python unfortunately.

    You could do all of your rendering to an in-memory image and then just update the image that the label is displaying but the paintEvent() override is a better option.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm building a small GUI-Test automation tool in C# for a application. One of
I'm building a small web project using Django that has one model ( Image
I'm building a small web app with Python on GAE. I have an HTML
I'm building a small web application with ASP.NET MVC 2, using db4o as a
I'm building a small scale forum script in PHP, and I am having difficulty
I'm building a small webshop in .net. The webshop solution will contain several webshops
ActiveX controls — small program building blocks — can serve to create distributed applications
i was building a new small website for an existing client, and thought about
I am currently looking at building an Open Source People Intelligence Application (Fancy Word
Im working on a database that store dates in a varchar(10) mysql field (so

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.