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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T14:39:25+00:00 2026-06-08T14:39:25+00:00

I have the problem that i want to set a Q_PROPERTY macro for my

  • 0

I have the problem that i want to set a Q_PROPERTY macro for my own class inherits by QGraphicsPixmapItem. So i my first property where i set the position works very well, but the second one where i want to set a rotation for the Qt::YAxis does not work and i dont know how to write it correctly. I need this propertys for an animation. Here is what im trying:

–A.h–

class myOwnPixmapItem : public QObject, public QGraphicsPixmapItem
{
    Q_OBJECT
    Q_PROPERTY (QPointF pos READ pos WRITE setPos)
    Q_PROPERTY (QTransform rot READ rot WRITE setRotation)

public:
    flowNpixmapItem()
};

–A.cpp–

myItemPosAnim -> setTargetObject (myItem);
myItemTransAnim -> setTargetObject (myItem);

myItemPosAnim -> setStartValue (QPointF (cover0 -> pos()));
myItemTransAnim -> setStartValue (QTransform::rotate (0, Qt::YAxis));
  • 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-08T14:39:27+00:00Added an answer on June 8, 2026 at 2:39 pm

    The problem is that QTransform::rotate is a non-static member function, meaning that this syntax can only be used to refer a function (function pointer), not to call the function.

    The method QPropertyAnimation::setStartValue takes a value (not a function) as its argument, so in your case a QTransform value. QTransform::rotate(...) (with arguments) is no value, indeed, it can’t be compiled because the compiler thinks you want to call the static method with the given arguments.

    So you probably want this:

    myItemPosAnim -> setTargetObject (myItem);
    myItemTransAnim -> setTargetObject (myItem);
    
    myItemPosAnim -> setStartValue (QPointF (cover0 -> pos()));
    QTransform transform;
    transform.rotate (0, Qt::YAxis):
    myItemTransAnim -> setStartValue (transform);
    

    But I still see a big problem in your code: You animate a transform, not the rotation itself. Rotation transformation is non-linear, meaning that if you try to animate a transformation from 0° to 180°, you would not get what you want. You would rather get a scaling animation, because 180° rotation equals scaling the coordinate system by factor -1. This is because scaling is a linear transformation, and QPropertyAnimation interpolates between the start and end value, so “the middle between start and end” is calculated using 0.5 * start + 0.5 * end, which is not what you want for rotation matrices.

    Since the rotation of QGraphicsItems is of type qreal anyway, just use this type:

    Q_PROPERTY (double rot READ rot WRITE setRotation)
    

    You should then use this like this:

    myItemPosAnim -> setTargetObject (myItem);
    myItemTransAnim -> setTargetObject (myItem);
    
    myItemPosAnim -> setStartValue (QPointF (cover0 -> pos()));
    myItemTransAnim -> setStartValue (0.0);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

with my RCP program I have the problem that I want to have more
I have the following problem that I want to solve in awk. I have
My problem is that I want to have a tab bar view with its
I have a problem with my site. I want that the shadow stops at
I have problem with fancybox. I want to write a function that will run
My problem is simple: I have a long list of elements that I want
I have a big problem. I want to extract text from html table that
I have the following problem. I want to check that the item clicked on
I have a problem that I want to create an Android App which captures
In a couple of scripts that I use I have problem that is intermittent.

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.