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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:29:24+00:00 2026-06-10T01:29:24+00:00

I have a question about Qt. I am wondering how it is I should

  • 0

I have a question about Qt. I am wondering how it is I should delete all the pointers I create. For example:

.h file

#ifndef MAINCALENDAR_H
#define MAINCALENDAR_H
#include<QWidget>
#include <QMap>
#include <QComboBox>
#include <QCalendarWidget>
#include <QRadioButton>
#include <QString>
#include <QtGui>
#include "selector.h"
#include <QInputDialog>

class mainCalendar : public QWidget
{
    Q_OBJECT
public:
    mainCalendar(QWidget * parent = 0);
    ~mainCalendar();
    void showAppointments();

public slots:
    void showLCFunc() {select->getTod()->getIntf()->getListClass().orderListChronologic(); printer * test = new printer; test->setList(TodFace->getList()); test->show();}
    void showLPFunc() {select->getTod()->getIntf()->getListClass().orderListByPriority(); printer * test = new printer; test->setList(TodFace->getList()); test->show();}
    void loadFile() {QString fileName = QFileDialog::getOpenFileName(this, tr("Open File"),"", tr("M-Calendar Files (*.mca)"));}
    void saveFile() {QString fileName = QFileDialog::getSaveFileName(this, tr("Save File"),"", tr("M-Calendar Files (*.mca)"));qDebug() << fileName << endl;}
    void intshow();
    void updater() {if (!Interface->isHidden()) { app->setList(Interface->getList()); app->Beta_update(1,calendar->selectedDate()); }
        else if (!TodFace->isHidden()) {tod->setList(TodFace->getList()); tod->Beta_update(1,calendar->selectedDate());} }

private:
    QPushButton *showLC;
    QPushButton *showLP;
    QPushButton *searchButton;
    QPushButton *updateButton;
    QPushButton *saveButton;
    QPushButton *loadButton;
    QLabel *instructions;
    QPushButton *backButton;
    QPushButton *taskButton;
    interface * Interface;
    todFace * TodFace;
    showTod * tod;
    showApp * app;
    QCalendarWidget *calendar;
    QGridLayout *mainLayout;
    Selector * select;
};

#endif // MAINCALENDAR_H

.cpp file:

#include "maincalendar.h"

mainCalendar::mainCalendar(QWidget *parent)
    : QWidget(parent)
{
    QHBoxLayout * footButtons = new QHBoxLayout;
    showLC = new QPushButton(tr("'to-do' (chrono)"));
    showLP = new QPushButton(tr("'to-do' (priority)"));
    searchButton = new QPushButton(tr("&Search"));
    saveButton = new QPushButton(tr("&Save calendar"));
    loadButton = new QPushButton(tr("&Load Calendar"));
    updateButton = new QPushButton(tr("Update"));
    footButtons->addWidget(searchButton);
    footButtons->addWidget(saveButton);
    footButtons->addWidget(loadButton);
    footButtons->addWidget(showLC);
    footButtons->addWidget(showLP);
    instructions = new QLabel(tr("To view or add data, double-click date in calendar"));
    calendar = new QCalendarWidget;
    calendar->setGridVisible(true);
    calendar->setMinimumDate(QDate(2012, 1, 1));
    calendar->setMaximumDate(QDate(2016,12,31));
    backButton = new QPushButton(tr("&Back to calendar"));
    select = new Selector(0,calendar,instructions,backButton, updateButton);


    tod = select->getTod();
    TodFace = tod->getIntf();
    TodFace->hide();
    TodFace->setCalendar(calendar);
    tod->hide();
    app = select->getApp();
    Interface = app->getIntf();
    Interface->hide();
    Interface->setCalendar(calendar);
    app->hide();



    backButton->hide();
    updateButton->hide();
    connect(showLC,SIGNAL(clicked()),this,SLOT(showLCFunc()));
    connect(showLP,SIGNAL(clicked()),this,SLOT(showLPFunc()));
    connect(updateButton, SIGNAL(clicked()), this, SLOT(updater()));
    connect(backButton, SIGNAL(clicked()), this, SLOT(intshow()));
    connect(loadButton,SIGNAL(clicked()),this,SLOT(loadFile()));
    connect(saveButton,SIGNAL(clicked()),this,SLOT(saveFile()));

    connect(calendar, SIGNAL(activated(QDate)), this, SLOT(intshow()));
    mainLayout = new QGridLayout;
    this->setMinimumHeight(800);
    this->setMinimumWidth(1000);
    mainLayout->setColumnMinimumWidth(0,500);
    mainLayout->addWidget(calendar,0,0);
    mainLayout->addWidget(app,1,0);
    mainLayout->addWidget(Interface,1,2);
    mainLayout->addWidget(tod,1,0);
    mainLayout->addWidget(TodFace,1,2);
    mainLayout->addWidget(backButton,0,0,Qt::AlignTop);
    mainLayout->addLayout(footButtons,2,0,Qt::AlignLeading);
    mainLayout->addWidget(instructions,2,0,Qt::AlignTrailing);
    mainLayout->addWidget(updateButton,2,2,Qt::AlignRight);
    setLayout(mainLayout);

    setWindowTitle(tr("M-Calendar"));
}

mainCalendar::~mainCalendar()
{
}

void mainCalendar::intshow()
{
    if (Interface->isHidden()&&TodFace->isHidden())
    {
        select->setDate(calendar->selectedDate());
        select->show();
        Interface->setdate(calendar->selectedDate());
        TodFace->setdate(calendar->selectedDate());
    } else
    {
        backButton->hide();
        updateButton->hide();
        Interface->hide();
        app->close();
        TodFace->hide();
        tod->close();
        calendar->show();
        instructions->show();
    }
}

I am stuck here. Am I supposed to do to delete all the pointers (QPushbutton, etc) and subclasses so no memory leaks occur?

  • 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-10T01:29:26+00:00Added an answer on June 10, 2026 at 1:29 am

    Short answer: No, you don’t have to explicitly delete them.

    In Qt, the QObjects are organized in object trees. The parent-child relationships of the various widgets also implies that the parent takes ownership of the child widgets.

    As a result you do not have to explicitly delete them when your application finishes. Each parent will take care of the cleanup of its own children. Only when you create a (pointer to) a widget/object which has no parent, you will need to explicitly delete it.

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

Sidebar

Related Questions

I have question about XSLT1.0. The task is to write out in HTML all
I have a question about the Required device capabilities item in the info.plist file.
I have a question about association multiplicity. I understand it, but for example if
I am wondering about this test question. I prepared the example myself and tested
I have a beginner's question. I was wondering about the level of subviews and
I have question about parsing in Html helper : I have sth like: @foreach
I have question about clean thory in Python. When: @decorator_func def func(bla, alba): pass
I have question about normalization. Suppose I have an applications dealing with songs. First
I have question about interpreting strings as packed binary data in C++. In python,
i have question about YAJLiOS parser... I have next json data : {{ body

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.