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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T12:39:29+00:00 2026-05-22T12:39:29+00:00

I am working on a small Tower Defense game in order to learn Qt.

  • 0

I am working on a small Tower Defense game in order to learn Qt. I am using a QGraphicsScene to hold all the object of the game. To make them move, I am not using the Animation framework but I’m calling the advance() method along with a QTimer.

I’d like to make my projectiles explode when they hit an enemy. The problem is that when I’m trying to draw an ellipse to simulate the explosion, it doesn’t get drawn correctly.

You can see the problem in this video.

I tried to play with the z-indexes but it didn’t change anything.

Here’s the code I use to draw the projectile :

void Projectile::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
    if(!isExploding) {
        painter->drawPixmap(boundingRect().toRect(), image);
    } else {
        if(cnt < 50) {
            painter->setBrush(QBrush(explosion));
            painter->drawEllipse(-cnt, -cnt, 2.0*cnt, 2.0*cnt);
            cnt++;
        } else {
            this->isFinished = 1;
        }
    }
}

QRectF Projectile::boundingRect() const
{
    // Taille de l'image de l'insecte
    return QRectF(0, 0, 6, 6);
}

Do you have any clues on how to solve this problem?

Thank you.

  • 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-05-22T12:39:30+00:00Added an answer on May 22, 2026 at 12:39 pm

    Say cnt is 3.
    You are drawing an ellipse with

    painter->drawEllipse(-3,-3,6,6)
    

    This would require a boundingRect with at least a width and height of 9.
    Also the boundingRect is specified using the internal item coordinate system. You are drawing from (-3,-3) to (6,6) which is outside of the boundingRect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Working on a small game using an HTML5 canvas, and javascript. And it's working
I'm working a small qt app (using PyQt4) and I've come up with an
I am working on small php application using codeigniter I did just copy paste
I've started working with cocos2d few days ago...and im working on small 2d game.
I'm working a small project, using AES encryption and wanted to use it in
I'm working on small documents compiler. I'm using .NET expression trees to create code
I'm working on a small templating engine, and I'm using DOMDocument to parse the
I'm working on a small php application using Zend Framework. I created a form
Iam working on small booking room system. In my solution I have a Reservation
I'm working on small web form,in C#/ASP.NET. I want to store the errors messages

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.