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. QGraphicsLineItem moveBy() doesn't really move the line, why?

QGraphicsLineItem moveBy() doesn't really move the line, why?

Scheduled Pinned Locked Moved General and Desktop
1 Posts 1 Posters 963 Views 1 Watching
  • 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.
  • jiapei100J Offline
    jiapei100J Offline
    jiapei100
    wrote on last edited by
    #1

    Hi, all:

    My code is as simple as:

    @QPointF end1 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p1();
    QPointF end2 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p2();
    std::cout << end1.x() << " " << end1.y() << std::endl;
    std::cout << end2.x() << " " << end2.y() << std::endl;

    dynamic_cast<QGraphicsLineItem*>(lineItem)->moveBy(dx, dy); // I'm pretty sure dx and dy are not 0

    end1 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p1();
    end2 = dynamic_cast<QGraphicsLineItem*>(lineItem)->line().p2();
    std::cout << end1.x() << " " << end1.y() << std::endl;
    std::cout << end2.x() << " " << end2.y() << std::endl;@
    To copy to clipboard, switch view to plain text mode

    two outputs of end1/end2 are always the same. However, I'm expecting there should be some difference, right?
    Why moveBy() doesn't really move two end points of such a QGraphicsLineItem ?
    How can I successfully move the end points then?

    cheers
    Pei

    Welcome to Longer Vision
    https://www.longervision.com

    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