Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. QPainter drawRects without draging a line behind
Forum Updated to NodeBB v4.3 + New Features

QPainter drawRects without draging a line behind

Scheduled Pinned Locked Moved Unsolved Game Development
gameqt5qpainterqvectorqrectf
2 Posts 2 Posters 594 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.
  • M Offline
    M Offline
    Mquaza
    wrote on last edited by Mquaza
    #1

    Hello, I am building a Snake game in QT 5.
    I am trying to draw the snakes body using a
    QVector<QRectF>. The class of the Snake is derived from QGraphicsItem so I am using paint method for drawing the object and head of the snake looks like
    QRectF(-20,-20,15,15). So I tried to add another object to the QVector after you collide with the food. The new QRectF was then
    QRectF(-35,-20,15,15) and it was drawn, but when you moved the snake to the right you were drawing a line.

    How do you make it so, that 2 rectangles are moving across the scene? Am I even in the right direction?

    Thanks for the help in advance.

    jsulmJ 1 Reply Last reply
    0
    • M Mquaza

      Hello, I am building a Snake game in QT 5.
      I am trying to draw the snakes body using a
      QVector<QRectF>. The class of the Snake is derived from QGraphicsItem so I am using paint method for drawing the object and head of the snake looks like
      QRectF(-20,-20,15,15). So I tried to add another object to the QVector after you collide with the food. The new QRectF was then
      QRectF(-35,-20,15,15) and it was drawn, but when you moved the snake to the right you were drawing a line.

      How do you make it so, that 2 rectangles are moving across the scene? Am I even in the right direction?

      Thanks for the help in advance.

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

      @Mquaza said in QPainter drawRects without draging a line behind:

      How do you make it so, that 2 rectangles are moving across the scene?

      I would say change their coordinates?

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

      1 Reply Last reply
      1

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved