I'm trying to prepare my Qt App (in C++) to be used by different user profiles: root user and normal user, so I want to hide specific root options (restricted QGroupBox) in normal user mode, and then when it's needed by a root user he could type it's password (in a security menu option, that I've already coded) to show them. Is that possible in the same GUI? I'm really stuck with this security implementation...
So, how could I code a hidden QGroupBox that will be shown only by root user when it's user/password is typed in the security menu option I mentioned before? How to implement that?
Is there an specific procedure in Qt to do that or any idea in other case?
Thanks a lot!
Last Update: I've used the @The Badger suggestions and have a first version that works just about as I wanted.
There are a few options:
Each time before the widget is drawn/shown, check what level of access the user has and depending on that show or hide controls:
void MyWidget::showEvent(QShowEvent * event) {
if(d_admin == true) {
ui->myAdminEdit->setVisible(true);
} else {
ui->myAdminEdit->setVisible(false);
}
/* Or one line */
ui->myAdminButton->setVisible(d_admin);
}
Or you connect a signal to show all of the admin widgets based on status:
/* In some constructor */
ui->myAdminEdit->setVisible(false);
ui->myAdminButton->setVisible(false);
connect(autClass, SIGNAL(adminLoggedIn(bool)), ui->myAdminEdit, SLOT(setVisible(bool)));
connect(autClass, SIGNAL(adminLoggedIn(bool)), ui->myAdminButton, SLOT(setVisible(bool)));
/* And then after authentication */
isAdmin = authenticate(username, password);
emit adminLoggedIn(isAdmin);
After the emit the widgets will become visible.