How to prevent open form?
-
Hi,
I use below code to open new UI form.mUrunAgacAl = new UrunAgacAl(this); mUrunAgacAl->showMaximized();I want to check authority of the user if he/she can open and use form?! In this case I check authorization in the setup section of the form before than below code;
ui->setupUi(this);My code is:
if(!auth){ QMessageBox::warning(this,"No permission!", "You can not use this form Exiting..."); this->close(); return; }But above code is not working. Form is still opening?!
I tyed also ;this->destroy(true,true);But still openning but emty page!
I just want to prevent opening form and delete from memort ofcourse?! How can I do it?
Regards,
Mucip:) -
Hi,
I use below code to open new UI form.mUrunAgacAl = new UrunAgacAl(this); mUrunAgacAl->showMaximized();I want to check authority of the user if he/she can open and use form?! In this case I check authorization in the setup section of the form before than below code;
ui->setupUi(this);My code is:
if(!auth){ QMessageBox::warning(this,"No permission!", "You can not use this form Exiting..."); this->close(); return; }But above code is not working. Form is still opening?!
I tyed also ;this->destroy(true,true);But still openning but emty page!
I just want to prevent opening form and delete from memort ofcourse?! How can I do it?
Regards,
Mucip:) -
Hi
Dont do it in the constructor.
Its too late there. Object being constructed at that moment.
so be much better if you did BEFORE creating the UrunAgacAl. -
@Mucip Why not
if(auth){ mUrunAgacAl = new UrunAgacAl(this); mUrunAgacAl->showMaximized(); } else { QMessageBox::warning(this,"No permission!", "You can not use this form Exiting..."); } -
Hi
Dont do it in the constructor.
Its too late there. Object being constructed at that moment.
so be much better if you did BEFORE creating the UrunAgacAl. -
Dear @mrjj ,
It's very difficult for me! It's better to make this control to form own!..Regards,
Mucip:) -
Hi
I agree with its not the best way but lets say we must do it.I was wondering cant you do like
mUrunAgacAl = new UrunAgacAl(this);
if (! UrunAgacAl->auth ) {
mUrunAgacAl->close();
mUrunAgacAl->deletelater();
} else
mUrunAgacAl->showMaximized();