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

  • Home
  • SEARCH
  • 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 7802499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:17:03+00:00 2026-06-02T01:17:03+00:00

Edit: Added more information. I’d like to rotate a QPolygonF around the origin illustrated

  • 0

Edit: Added more information.

I’d like to rotate a QPolygonF around the origin illustrated below:

block rotations

I’d like this polygon (centre of image is origin – 0, 0):

first polygon

To rotate clockwise so that it ends up here:

enter image description here

The QPolygonF has points in the same position as the first block in the image above:

QPolygonF p1 =  QPolygonF() << QPointF(0, 1) << QPointF(4, 1) << QPointF(4, 2) << QPointF(0, 2);

I then rotate around what I think is the correct origin (2, 2):

QTransform t;
t.translate(2, 2);
t.rotate(-90);
t.translate(-2, -2);
QPolygonF p2 = t.map(p1);
qDebug() << p1 << "rotated = " << p2;

Output:

QPolygonF(QPointF(0, 1) QPointF(4, 1) QPointF(4, 2) QPointF(0, 2) ) rotated =  QPolygonF(QPointF(1, 4) QPointF(1, 0) QPointF(2, 0) QPointF(2, 4) )

When the output that I want is:

QPolygonF(QPointF(0, 1) QPointF(4, 1) QPointF(4, 2) QPointF(0, 2) ) rotated =  QPolygonF(QPointF(2, 0) QPointF(3, 0) QPointF(3, 4) QPointF(2, 4) )

But, according to the output above, the polygon would end up looking like this:

wrong rotation

At which point should I be rotating around?

  • 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-02T01:17:04+00:00Added an answer on June 2, 2026 at 1:17 am

    Edit

    After working out what you are after I now know the right code to achieve this:

    QTransform t; 
    t.translate(2, 2); 
    t.rotate(90); 
    t.translate(-2, -2); 
    QPolygonF p2 = t.map(p1); 
    qDebug() << p1 << "rotated = " << p2;
    

    Which will give the rectangle:

    QPolygonF(QPointF(3, 0) QPointF(3, 4) QPointF(2, 4) QPointF(2, 0) )
    

    Which is what you expect (although the ordering is change due the rotation). It’s worth noting that rotate(90) and rotate(-90) will not give the same result as you are rotating about the edge of the rectangle, not the middle of it.

    Conceptualising QT tranforms

    Some confusion may arise because of the direction of the qt rotate function. Although this will enact a counter clockwise rotation, because we “see” the y-axis inverted (at least in this case) it appears clockwise to us.

    As an analogy if I’m in a room and observer a lamp falling over to the left,
    from the point of view of someone hanging on the cieling it has “fallen over” to the right.

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

Sidebar

Related Questions

EDIT I added this note to explain why I keep this question here. I
EDIT: Modified title and added update. UPDATE : We no longer believe this is
in C# I'd like to invoke the label edit of a newly added item
EDIT: I will leave this here as an example. Read the comments for more
--Edit with more bgnd information-- A (black box) COM object returns me a string.
Edit: Added code (Exception on line 095, 5th time it's hit.) public DataTable ParseBarcodes(String[]
EDIT: I added in where I create new instance of the class Process as
Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
EDIT : Accepted answer points out what my issue was. I added another answer
I have a piece of code: EDIT: The _penParams are initialized as the added

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.