Results 1 to 3 of 3

Thread: Widgets wich depended from user permissions

  1. #1
    Join Date
    Aug 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Question Widgets wich depended from user permissions

    Hi everybody.
    My question is this :
    I am currently developing a program on qt 4.7.3
    I want that a part of my widgets would be dependent from user permissions.
    For example,I want make, invisible a widget (if any user not have the desired permissions)
    Is it possible to do so, even at the stage of development, for example by definition any property?

    I dont want to write in my application a following code:
    QWidget * myWidget = ....
    ...
    myWidget->setVisible(permissions == Admin || permissions == Manager);

  2. #2
    Join Date
    Jan 2009
    Location
    Germany
    Posts
    131
    Thanks
    11
    Thanked 16 Times in 16 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Widgets wich depended from user permissions

    You could do something like this (not compilable!, just to get the idea):

    Qt Code:
    1. PermissionManager* manager = getPermissionManager();
    2.  
    3. foreach(widget, all-widgets-that-should-depend-on-permissions) {
    4. manager->registerWidget(widget, Permission::Admin | Permission::Manager);
    5. }
    6.  
    7. // later
    8.  
    9. void onPermissionChange(Permission::Type permission) {
    10. PermissionManager* manager = getPermissionManager();
    11. manager->setUserPermission(permission)
    12. }
    13.  
    14. // implementation could be like this
    15.  
    16. PermissionManager::setUserPermission(Permission::Type permission) {
    17.  
    18. foreach(widget, widget-list) {
    19. Permissions permissions = getPermissionsForWidget(widget);
    20. widget->setVisible(permissions is valid permission));
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

    You could also install a EventHandler an watch for the visible/enable events and control the permissions there. This would also catch if a widget is made visible directly. Interesting for implementation could be

    1. QFlags
    2. QObject::installEventHandler

  3. #3
    Join Date
    Aug 2011
    Posts
    7
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Smile Re: Widgets wich depended from user permissions

    Thank you very much nightghost
    But I really thought that there is already something similar in Qt.
    Probably I going to use your idea
    Thanks!!!!!!!!!!!

Similar Threads

  1. Widgets: Let the user change the size
    By Donner in forum Qt Programming
    Replies: 2
    Last Post: 14th November 2010, 20:13
  2. Finding user permissions
    By doggrant in forum Qt Programming
    Replies: 6
    Last Post: 22nd October 2009, 19:05
  3. how do I discard user changes on widgets
    By donglebob in forum Qt Programming
    Replies: 5
    Last Post: 30th December 2008, 07:50
  4. Replies: 3
    Last Post: 11th September 2008, 20:08

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.