Results 1 to 2 of 2

Thread: Smart way to enable/disable Controls

  1. #1
    Join Date
    Sep 2014

    Question Smart way to enable/disable Controls


    whats the smartest way to enable or disable controls (control groups) in Qt?
    I want to use something like an ACL (Access Controll List) in combination with QStateMachine to realize this.
    Or is there a way to directly connect an ACL to controls? I.e. if a signal is emited like signalUserRoleChanged that I can connect this signal to a ControlGroup and this control group has a property with roles allowed to access this control group (Whitelist) and if the new role matches the whitelist so the controls should be enabled otherwise the controls should be disabled.

    Aktually Iam using the verry messy method like this:
    Qt Code:
    1. if(member()->isAdmin()) {
    2. m_ui->actionUserManager->setEnabled(true);
    3. m_ui->actionModuleControl->setEnabled(true);
    4. m_ui->actionProgramControl->setEnabled(true);
    5. m_ui->actionReportControl->setEnabled(true);
    6. } else {
    7. m_ui->actionUserManager->setEnabled(false);
    8. m_ui->actionModuleControl->setEnabled(false);
    9. m_ui->actionProgramControl->setEnabled(false);
    10. m_ui->actionReportControl->setEnabled(false);
    11. }
    To copy to clipboard, switch view to plain text mode 


  2. #2
    Join Date
    Jan 2006
    Graz, Austria
    Thanked 1,546 Times in 1,496 Posts
    Qt products
    Qt3 Qt4 Qt5
    Unix/X11 Windows

    Default Re: Smart way to enable/disable Controls

    If you change state in your state machine when you can use the state's assignProperty mechanism to change the enabled property.

    If not, you could attach role information on each widget and then, at a central place, walk through the widgets and set enable/disable depending on the current role and the attached data.


Similar Threads

  1. Enable and Disable Close (X)
    By anh5kor in forum Newbie
    Replies: 2
    Last Post: 25th March 2015, 07:45
  2. disable enable network connections?
    By remy06 in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2009, 18:52
  3. disable/enable shortcut
    By harakiri in forum Qt Programming
    Replies: 2
    Last Post: 6th May 2007, 11:58
  4. How to disable 3 controls on the main application
    By sarode in forum Qt Programming
    Replies: 9
    Last Post: 30th January 2007, 13:37
  5. Replies: 4
    Last Post: 31st August 2006, 13:11


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.