Close and Delete QMainWindow and Confirm it Deleted
Dear All ,
I have written an application where for every class I have own set of variable and function and To move to new class I have to close previous class object and creating new controuctor for the class I am going to open ;
A class (closing A class Variable Opening B Class) --> B Class
B Class (closing B class Variable Opening C Class )--> C class
A class (closing A class Variable Opening M Class) --> M Class
A class (closing A class Variable Opening N Class) --> N Class
M class (closing M class Variable Opening A Class) --> A Class
N Class (closing N class Variable Opening A Class )--> A class
Its a random sequence ;
for closing class I am performing the same
and Before that I am openning new class
myActvAlrm = new ActiveAlarms(); myActvAlrm->showFullScreen(); myActvAlrm->show();
but It that I am not able to be so sure the object are deleted ;
and what I found Some times I saw Segmentation Fault :error 139 that I found on searching that it is acess the pionter; which either out of application range and returning 0 and result it crashes ;
Pls help at what point I am lagging ;
What type of classes are you copying? Do take into consideration that a copy of a QObject is NOT possible.
Your code is a bit slim. How and where do you create and delete the classes?
Thanks for Reply !
int main(int argc, char *argv)
QApplication a(argc, argv);
homescr::homescr(QWidget *parent) : QDialog(parent),
UpdatScr = new QTimer(this);
myMeterScr_1 = new Meter(); myMeterScr_1->showFullScreen(); myMeterScr_1->show(); UpdatScr->stop(); UpdatScr->deleteLater(); homescr::close();
GWin->RTClock(); //Access function from other class
ui->TimeLable->setAutoFillBackground(true); ui->TimeLable->setPalette(sample_palette); ui->Date_Lable->setText(Dat); ui->TimeLable->setText(Tim);
Pls do suggest is any thind gone wrong !!
Your design makes me think of something like a strange wizard. Also myMeterScr_1 is leaking, you don't delete it anywhere.
UpdatScr should rather be a single shot since it seems it's fired only once.
homescr::close(); is a call to a static function, you should just call close();
As SGaist said, your overall flow,object creation and deletion will surely mess up things. My suggestion is to re-think on over-all handling of your flow and object creation. Current flow has memory leaks, objects are closed unnecessarily.
Happy for re-design.