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. ellipse->setPos(X,Y) gives me an error.
QtWS25 Last Chance

ellipse->setPos(X,Y) gives me an error.

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 748 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.
  • B Offline
    B Offline
    bask185
    wrote on last edited by
    #1

    I had it working last week, but then I changed something and now I get:

    invalid use of incomplete type ‘class QGraphicsEllipseItem’
                               ellipse->setPos(X,Y);
    
                                      ^
    

    In the contstructor:

      scene = new QGraphicsScene(this);
      ui->graphicsView_1->setScene(scene);
    
      QBrush greenBrush(Qt::green);
      QBrush yellowBrush(Qt::yellow);
      QBrush redBrush(Qt::red);
      QBrush greyBrush(Qt::gray);
      QPen outlinePen(Qt::black);
      outlinePen.setWidth(0);
    
      rectangle = scene->addRect(0, 0, 140, 140, outlinePen, redBrush);
      rectangle = scene->addRect(40, 40, 100, 100, outlinePen, greenBrush);
      rectangle = scene->addRect(60, 60, 80, 80, outlinePen, greyBrush);
      ellipse = scene->addEllipse(50, 50, 10, 10, outlinePen, yellowBrush);
    

    And header file:

        QGraphicsScene *scene;
        QGraphicsRectItem *rectangle;
        QGraphicsEllipseItem *ellipse;
        QGraphicsLineItem *horizontalLine, *verticalLine;
        QGraphicsView *graphicsView_1;
    

    It are 3 colored rectangled with a yellow dot in the middle. The dot gets drawn but I need it to move around when a machine sends data. I am trying to use the setPos() function but that gives the error.

    What am I doing wrong

    jsulmJ 1 Reply Last reply
    0
    • B bask185

      I had it working last week, but then I changed something and now I get:

      invalid use of incomplete type ‘class QGraphicsEllipseItem’
                                 ellipse->setPos(X,Y);
      
                                        ^
      

      In the contstructor:

        scene = new QGraphicsScene(this);
        ui->graphicsView_1->setScene(scene);
      
        QBrush greenBrush(Qt::green);
        QBrush yellowBrush(Qt::yellow);
        QBrush redBrush(Qt::red);
        QBrush greyBrush(Qt::gray);
        QPen outlinePen(Qt::black);
        outlinePen.setWidth(0);
      
        rectangle = scene->addRect(0, 0, 140, 140, outlinePen, redBrush);
        rectangle = scene->addRect(40, 40, 100, 100, outlinePen, greenBrush);
        rectangle = scene->addRect(60, 60, 80, 80, outlinePen, greyBrush);
        ellipse = scene->addEllipse(50, 50, 10, 10, outlinePen, yellowBrush);
      

      And header file:

          QGraphicsScene *scene;
          QGraphicsRectItem *rectangle;
          QGraphicsEllipseItem *ellipse;
          QGraphicsLineItem *horizontalLine, *verticalLine;
          QGraphicsView *graphicsView_1;
      

      It are 3 colored rectangled with a yellow dot in the middle. The dot gets drawn but I need it to move around when a machine sends data. I am trying to use the setPos() function but that gives the error.

      What am I doing wrong

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @bask185 Did you include QGraphicsEllipseItem header file where you call ellipse->setPos(X,Y)?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • B Offline
        B Offline
        bask185
        wrote on last edited by
        #3

        I did now and it solved the problem, tnx ;)

        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