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. After the coordinate transformation(setRotation()) is how can I get it?

After the coordinate transformation(setRotation()) is how can I get it?

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 819 Views
  • 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.
  • DaryongD Offline
    DaryongD Offline
    Daryong
    wrote on last edited by
    #1

    Hello.

    I added the QGraphicsScene to QGraphicsLineItem.
    and rotate LineItem.

    How can I rotated a LineItem coordinates ?

    < source >
    QGraphicsLineItem* pTestLineItem = _scene.addLine( 300, 300, 500, 300, QPen( Qt::red ) );

    pTestLineItem->setTransformOriginPoint( pTestLineItem->boundingRect().center() );
    pTestLineItem->setRotation( 30. );

    QPointF p1 = pTestLineItem->line().p1();
    QPointF p2 = pTestLineItem->line().p2();

    p1, p2 is no changed.
    p1( 300, 300 ) and p2(500, 300 )

    thanks.

    D 1 Reply Last reply
    0
    • DaryongD Daryong

      Hello.

      I added the QGraphicsScene to QGraphicsLineItem.
      and rotate LineItem.

      How can I rotated a LineItem coordinates ?

      < source >
      QGraphicsLineItem* pTestLineItem = _scene.addLine( 300, 300, 500, 300, QPen( Qt::red ) );

      pTestLineItem->setTransformOriginPoint( pTestLineItem->boundingRect().center() );
      pTestLineItem->setRotation( 30. );

      QPointF p1 = pTestLineItem->line().p1();
      QPointF p2 = pTestLineItem->line().p2();

      p1, p2 is no changed.
      p1( 300, 300 ) and p2(500, 300 )

      thanks.

      D Offline
      D Offline
      Devopia53
      wrote on last edited by
      #2

      Hi, @Daryong

      pTestLineItem->line().p1() is origin coordinate before rotated it. Also always returned origin.

      If you want to know the rotated coordinates, you must use mapping methods.

      Something like this:

      QPointF p1 = pTestLineItem->mapToScene(pTestLineItem->line().p1());
      
      DaryongD 1 Reply Last reply
      1
      • D Devopia53

        Hi, @Daryong

        pTestLineItem->line().p1() is origin coordinate before rotated it. Also always returned origin.

        If you want to know the rotated coordinates, you must use mapping methods.

        Something like this:

        QPointF p1 = pTestLineItem->mapToScene(pTestLineItem->line().p1());
        
        DaryongD Offline
        DaryongD Offline
        Daryong
        wrote on last edited by
        #3

        @Devopia53 Ok, Thank you very much. ^^

        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