Results 1 to 11 of 11

Thread: QGroupBox enabling problem

  1. #1
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QGroupBox enabling problem

    I have QGroupBox and widgets inside one. If I want to disable all these widgets I write
    Qt Code:
    1. mygroupBox->SetEnabled(false);
    To copy to clipboard, switch view to plain text mode 
    If I want to enable all widgets I write
    Qt Code:
    1. mygroupBox->SetEnabled(true);
    To copy to clipboard, switch view to plain text mode 

    But if the groupbox is disabled initially (for ex I set this in QtCreator) then I can not enable it in run-time.

  2. #2
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGroupBox enabling problem

    Could you please provide some code?

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGroupBox enabling problem

    Its setEnabled , not SetEnabled

  4. #4
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGroupBox enabling problem

    I guess he miswrote it since he got no errors in compile time.

  5. #5
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QGroupBox enabling problem

    I guess he miswrote it since he got no errors in compile time.
    May be.

    then I can not enable it in run-time.
    How are you trying to enable it at runtime ? Need to see some code

  6. #6
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGroupBox enabling problem

    The code is very very simple:
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. ui->markersGroupBox->setEnabled(!ui->markersGroupBox->isEnabled());
    4. }
    To copy to clipboard, switch view to plain text mode 
    it works only if I enabled groupbox initially (in Qt Creator)

  7. #7
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGroupBox enabling problem

    This works for me. Maybe you have disabled your widget somewhere else in the code? Or one of it's parent still disabled..

  8. #8
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGroupBox enabling problem

    Try to disable groupbox at design time

  9. #9
    Join Date
    Dec 2008
    Location
    Istanbul, TURKEY
    Posts
    537
    Thanks
    14
    Thanked 13 Times in 13 Posts
    Qt products
    Qt4
    Platforms
    Windows Android

    Default Re: QGroupBox enabling problem

    That's already what I did.

    I disabled the group box from the designer and I run the program. Each button press toggles the enability of the group box as usual. You mean something different?

  10. #10
    Join Date
    Feb 2010
    Location
    Russia, Omsk
    Posts
    28
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGroupBox enabling problem

    Very strange. Could you provide your project, please.

  11. #11

    Default Re: QGroupBox enabling problem

    Hi guys

    I ran into the same problem today but I could solve it. The problem seems to be in the QTDesigner Application.
    When you add a new QGroupBox and add some elements to it, everything works fine. But if you manually set Enable to false on one of the elements while the QGroupBox is checked the mechanism doesn't work anymore for this element, even if you manually set enable to true again.
    So to solve this I opened the related .ui file in a Texteditor. Under the element you once set to enable=false you will find the following tag:
    Qt Code:
    1. <property name="enabled">
    2. <bool>false</bool>
    3. </property>
    To copy to clipboard, switch view to plain text mode 
    Just remove this whole block and everything works fine again.
    Short: If you want the GroupBox to automatically enable/disable it's childrens, never ever touch the childrens enabled property!
    I hope you understand what I'm trying to say
    Cheers

Similar Threads

  1. QGroupBox size problem
    By MarkoSan in forum Newbie
    Replies: 2
    Last Post: 22nd November 2009, 18:44
  2. Problem with enabling QPushButton!
    By Krish in forum Newbie
    Replies: 6
    Last Post: 5th March 2008, 14:49
  3. Replies: 2
    Last Post: 19th May 2007, 18:25
  4. enabling/disabling a QMainWindow?
    By TheRonin in forum Qt Programming
    Replies: 20
    Last Post: 5th April 2007, 12:36
  5. Problem in enabling QtreeWidget items dynamically
    By jyoti kumar in forum Qt Programming
    Replies: 10
    Last Post: 7th June 2006, 18:10

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.