Results 1 to 5 of 5

Thread: How to disable all widgets on MainWindow except one

  1. #1
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default How to disable all widgets on MainWindow except one

    With
    mainWindow->enable(false);

    i can disable all widgets on it. But i want one of the widgets NOT to be disabled. Any ideas?
    Of course i can disable them one by one, but it is lot of (inefficient) code.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: How to disable all widgets on MainWindow except one

    With some tricks you can find all widgets on your main window using QObject::findChildren() or QObject::children(). Then loop through them and disable them.

  3. The following user says thank you to Lykurg for this useful post:

    BIllNo123 (26th August 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to disable all widgets on MainWindow except one

    Thanks Lykurg!
    A notice: By doing
    mainWindow->setEnabled(true);

    it enables all widgets except those that were explicitly disabled, e.g. widget1->setDisabled(true);
    In other words, it works the other way...

  5. #4
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to disable all widgets on MainWindow except one

    Quote Originally Posted by Lykurg View Post
    With some tricks you can find all widgets on your main window using QObject::findChildren() or QObject::children(). Then loop through them and disable them.
    Problem still. There is hierarchy between widgets so if i disable a parent then all children are disabled and they can't be enabled after that!

  6. #5
    Join Date
    Aug 2010
    Posts
    16
    Thanks
    6
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to disable all widgets on MainWindow except one

    Problem solved. I had to disable it in pieces.

Similar Threads

  1. Change Widgets in the center of MainWindow.
    By Trader in forum Qt Programming
    Replies: 1
    Last Post: 23rd July 2010, 04:46
  2. How to put 2 Widgets in a MainWindow ?
    By gen_mass in forum Newbie
    Replies: 13
    Last Post: 1st July 2010, 12:01
  3. Qt Designer : Layouts disable widgets :( !!!
    By QAmazigh in forum Qt Programming
    Replies: 1
    Last Post: 10th May 2009, 14:48
  4. Child Widgets In MainWindow
    By RY in forum Newbie
    Replies: 3
    Last Post: 4th October 2008, 08:39
  5. scrolled widgets containers in Mainwindow
    By antonio.r.tome in forum Qt Programming
    Replies: 1
    Last Post: 24th October 2006, 14:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.