MenuBar show Menu or Hide
-
Hello Users,
i have a little problem with my menuBar. I will do a login function with loginButton. If there user an admin he see the completly menuBar. At first the menu is false (setVisible).
@ui->menuBar->setVisible(false);@
If the user an admin:
@if(status == "admin")
{
ui->menuBar->setVisible(true);
ui->groupBox->hide();
}@When the User is an user:
@else if(status == "user")
{
ui->groupBox->hide();
}
else
QMessageBox::information(this,"Info","Bitte ein gramatikalisch, richtiges Password eingeben");@The problem is i can´t show the right menu. I have three task in the menu:
- File
- Edit
- Database
an i will see file and edit and not database. I have continue follow syntax:
@else if(status == "user")
{
ui->groupBox->hide();
ui->menuDatei->setVisible(true);
ui->menuBearbeiten->setVisible(true);
}@But the context is open at the left corner and not in the MainWindow.
Have anybody a idea about it?Alex from Germany
-
http://imagizer.imageshack.us/a/img196/633/5k5d.png
Hier ist das Bild. Ist leider nur 9 Tage online
-
Hi guys,
Please keep the thread in English, it's the official language to communicate on the forum (except for the regional sub-forums)
As for your problem, it looks more like hiding a menu itself rather than the menu bar, or did I understand wrong ?
-
There's always the "german forum":http://qt-project.org/forums/viewforum/30/ for that :)
-
Don't worry abour your english ;) Ok, I think the easiest way to realize it is
@int iUserLevel = 0;
enum UserLevel { eUSER = 0, eADMIN, };int checkUserlevel()
{
if(iUserLevel == eADMIN)
{
ui->menu_Datei ->setEnabled(true);
ui->menu_Bearbeiten ->setEnabled(true);
ui->menu_Datenbank ->setEnabled(true);} else if(iUserLevel == eUSER) { ui->menu_Datei ->setEnabled(true); ui->menu_Bearbeiten ->setEnabled(true); ui->menu_Datenbank ->setEnabled(false); }return 0;
}
@Or is it a problem if the user can see the database item? I prefer to work with enumerations for the userlevel because it is better to handle than strings.
-
Hello,
this idea:
@ui->menu_Datei ->setEnabled(true);
ui->menu_Bearbeiten ->setEnabled(true);
ui->menu_Datenbank ->setEnabled(false);@is not bad. This idea is god and the User can´t clicked the menuItem, but in another program i will the user can´t see the database item.
Okay. I must look what i do for this problem. But this is a start in the right way.Thanks for help :-)
Alex
-
Then you can change setEnabled by setVisible for the items that should be invisible to the user
-
With the menu not visible ? How do you do that ?
-
Can you show an image of what you get both with setVisible(true) and setVisible(false) ?