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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:05:53+00:00 2026-06-10T21:05:53+00:00

I’m new here and i can’t solve this thing. I have a QGraphicScene (which

  • 0

I’m new here and i can’t solve this thing.
I have a QGraphicScene (which at first initializes a Cartesian plane) in which it draw points \ lines with the methods AddLine \ ecc.Everything works.But I want to have a method that delete all “objects” drawn on the scene and reloads the cartesian plane.Any suggestion?

Here you can find my classes:

class draw: public QWidget
{
    Q_OBJECT

private:

    QGraphicsScene scene;
    int x1;
    int y1;
    int x2;
    int y2;

public:
    disegna (QWidget *parent = 0);
    void setdot(QString,QString);
    void setsegment(QString,QString,QString,QString);
    ~disegna(){}
    };

draw::draw(QWidget *parent) : QWidget(parent) { 
    scene.setBackgroundBrush(Qt::white);
    scene.addRect(QRectF(0,0, 600, 200));
    scene.addLine(0, 100 ,600, 100);
    scene.addLine(300, 0 ,300, 200);
    scene.addEllipse(297.5,97.5,5,5,QPen(), QBrush(Qt::red));

    int i=0;
    for (int a=0;a<120;a++) {
        scene.addLine(i+5, 98 ,i+5, 102);
        i=i+5;
    }

    int j=0;
    for (int a=0;a<40;a++) {
        scene.addLine(298,j+5,302,j+5);
        j=j+5;
    }

    QGraphicsView * view = new QGraphicsView(&scene,this);
    view->show();
}

void draw::setdot(QString x1,QString y1){
    scene.addEllipse(x1.toInt()+298, 98-y1.toInt(),4,4,QPen(), QBrush(Qt::blue));
}

void draw::setsegment(QString x1,QString y1,QString x2,QString y2) {
    scene.addLine(x1.toInt()+300, 100-y1.toInt(),x2.toInt()+300, 100-y2.toInt(),QPen());
    scene.addEllipse(x1.toInt()+298, 100-y1.toInt(),4,4,QPen(), QBrush(Qt::blue));
    scene.addEllipse(x2.toInt()+298, 100-y2.toInt(),4,4,QPen(), QBrush(Qt::blue));
}
  • 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-06-10T21:05:54+00:00Added an answer on June 10, 2026 at 9:05 pm

    For cleaning the scene, did you tried the clear method ?

    If you want to clear and redraw, I suggest you to move the drawing code from your constructor to a method.
    Then you can call clear then your drawing method.

    Hope it helps

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a jquery bug and I've been looking for hours now, I can't
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have an autohotkey script which looks up a word in a bilingual dictionary
I have a text area in my form which accepts all possible characters from

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.