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 8507327
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:50:24+00:00 2026-06-11T02:50:24+00:00

I am sub-classing a QLabel and am trying to rotate it as the user

  • 0

I am sub-classing a QLabel and am trying to rotate it as the user drags (or rotates) an image with the mouse. Currenty I am just rotating clock-wise with every mouse moved event:

void RotoTest::slotMouseMoved()
{
    currentRotation += 1;
    rotate(currentRotation % 360);
}

void RotoTest::rotate(int degree)
{
    QPixmap pixmap(originalPixmap);
    QPixmap rotatedMap(pixmap.size());
    QPainter p(&rotatedMap);
    p.translate(pixmap.size().width() / 2, pixmap.size().height() / 2);
    p.rotate(degree);
    p.translate(-pixmap.size().width() / 2, -pixmap.size().height() / 2);
    p.drawPixmap(0, 0, pixmap);
    this->setPixmap(rotatedMap);
}

This works and rotates, but the problem is that the image becomes very laggy, jittery and unresponsive, especially the quicker or longer the mouse is moved for a given instance. I suspect this is happening due to the large amount of signals being sent when the mouse moves. Does anybody have any suggestions for a way for a nice smooth rotation? I am looking for the image to rotate as nicely as the QDial does.

  • 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-06-11T02:50:26+00:00Added an answer on June 11, 2026 at 2:50 am

    It is not clear to me without seeing more code, but possibly it is too many events piling up. If that’s the case, then 1) it’s a surprise since Qt is supposed to quietly take care of compressing many identical events into a few and 2) you can do it yourself by throttling calls to update() in your slot code handling the input event. (Or, since you’re subclassing QLabel, it would go somewhere…?)

    See http://qt-project.org/forums/viewthread/12257 for explanation and code.

    Then again, this could be barking up the wrong tree entirely. That’s why we have downvote buttons 😉

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

Sidebar

Related Questions

I want to make simple classic inheritance with JavaScript. I just need sub classing
I'm dynamically sub classing a generic type (filling it's contract) that has a generic
I'm implementing custom behavior sub-classing the form controls, but I cannot manage to access
Say I'm sub-classing (extending) Ember.View to create My.Widget. I'd like each My.Widget sub-class to
I can solve the problem of adding functionality by adding sub classing then why
When sub-classing AbstractCollection , I must still implement size() , even though (I believe)
I wrote my own model sub-classing from QAbstractItemModel , and I am using QTableView
Solved: see answer below I am sub-classing Dialog to create a dialog with a
How should I write an init method for a class which is sub-classing an
I tried sub-classing the QTableWidgetItem and then set my horizontalHeaderItem with that new sub-classed

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.