Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Buttons in layout enabled but not accessible.
Forum Updated to NodeBB v4.3 + New Features

Buttons in layout enabled but not accessible.

Scheduled Pinned Locked Moved Solved General and Desktop
10 Posts 3 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • SPlattenS Offline
    SPlattenS Offline
    SPlatten
    wrote on last edited by SPlatten
    #1
    This post is deleted!
    JonBJ 1 Reply Last reply
    0
    • SPlattenS SPlatten

      This post is deleted!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @SPlatten
      Continue back up the hierarchy of QWidget parents. I believe you will find one of them is disabled, and this results in descendants being disabled even if their own isEnabled() returns true?

      SPlattenS 1 Reply Last reply
      1
      • JonBJ JonB

        @SPlatten
        Continue back up the hierarchy of QWidget parents. I believe you will find one of them is disabled, and this results in descendants being disabled even if their own isEnabled() returns true?

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #3

        @JonB, I've tried the following:

                    QHBoxLayout* pobjHBox(qobject_cast<QHBoxLayout*>(mpobjLO));
                    if ( pobjHBox != nullptr ) {
                        pobjHBox->addWidget(pobjButton);
        bool blnEnabled(pobjButton->isEnabled()), blnLOEnabled(pobjHBox->isEnabled());
        qdbg() << blnEnabled << blnLOEnabled;
        

        mpobjLO is the layout containing the buttons, the layout containing this layout is most definitely enabled and other controls within the form are selectable and editable.

        The button is enabled, so is the layout, but the buttons appear greyed and I cannot click on them.

        JonBJ 1 Reply Last reply
        0
        • JoeCFDJ Offline
          JoeCFDJ Offline
          JoeCFD
          wrote on last edited by JoeCFD
          #4

          Try this although normally the button is disabled if their parents are disabled.
          qdbg() << pobjButton->isEnabled() << " " << pobjButton->parentWidget()->isEnabled() << " " << pobjButton->parentWidget()->parentWidget()->isEnabled() ;

          1 Reply Last reply
          1
          • SPlattenS SPlatten

            @JonB, I've tried the following:

                        QHBoxLayout* pobjHBox(qobject_cast<QHBoxLayout*>(mpobjLO));
                        if ( pobjHBox != nullptr ) {
                            pobjHBox->addWidget(pobjButton);
            bool blnEnabled(pobjButton->isEnabled()), blnLOEnabled(pobjHBox->isEnabled());
            qdbg() << blnEnabled << blnLOEnabled;
            

            mpobjLO is the layout containing the buttons, the layout containing this layout is most definitely enabled and other controls within the form are selectable and editable.

            The button is enabled, so is the layout, but the buttons appear greyed and I cannot click on them.

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @SPlatten
            What @JoeCFD has written is what I wanted you to check (widget parentage). Do that first.

            An alternative issue would be QButtonGroup::setExclusive(). Set that to false. Is that where your disablement is coming from?

            SPlattenS 1 Reply Last reply
            0
            • JonBJ JonB

              @SPlatten
              What @JoeCFD has written is what I wanted you to check (widget parentage). Do that first.

              An alternative issue would be QButtonGroup::setExclusive(). Set that to false. Is that where your disablement is coming from?

              SPlattenS Offline
              SPlattenS Offline
              SPlatten
              wrote on last edited by
              #6

              @JonB & @JoeCFD , just added:

              qdbg() << "HACK: " << pobjButton->isEnabled() << " " << pobjButton->parentWidget()->isEnabled() << " " << pobjButton->parentWidget()->parentWidget()->isEnabled() ;
              

              I added "HACK:" so I can search the Application Output , the result is:

              S000000000068E000000161861T16:09:33.535DL00000139F../clsQtLayout.cpp[void clsQtLayout::addButton]
              HACK: true true true
              S000000000069E000000164553T16:09:36.227D:HACK: true true true
              S000000000070E000000165670T16:09:37.344D:HACK: true true true
              

              3 times because there are 3 buttons I the layout.

              1 Reply Last reply
              0
              • JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by
                #7

                add the following in this class
                protected:
                virtual void showEvent( QShowEvent * ) override;

                add your following code inside showEvent( )
                qdbg() << "HACK: " << pobjButton->isEnabled() << " " << pobjButton->parentWidget()->isEnabled() << " " << pobjButton->parentWidget()->parentWidget()->isEnabled() ;

                this will tell you if they are enabled or not when they are displayed.

                SPlattenS 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  add the following in this class
                  protected:
                  virtual void showEvent( QShowEvent * ) override;

                  add your following code inside showEvent( )
                  qdbg() << "HACK: " << pobjButton->isEnabled() << " " << pobjButton->parentWidget()->isEnabled() << " " << pobjButton->parentWidget()->parentWidget()->isEnabled() ;

                  this will tell you if they are enabled or not when they are displayed.

                  SPlattenS Offline
                  SPlattenS Offline
                  SPlatten
                  wrote on last edited by
                  #8

                  @JoeCFD said in Buttons in layout enabled but not accessible.:

                  virtual void showEvent( QShowEvent * ) override;

                  The trouble is I've done something very clever or very stupid, several months ago and now I'm trying to revisit it and see what I've done, if I add another button which has different properties it works fine, so this is NOT a Qt issue.

                  JoeCFDJ 1 Reply Last reply
                  0
                  • SPlattenS SPlatten

                    @JoeCFD said in Buttons in layout enabled but not accessible.:

                    virtual void showEvent( QShowEvent * ) override;

                    The trouble is I've done something very clever or very stupid, several months ago and now I'm trying to revisit it and see what I've done, if I add another button which has different properties it works fine, so this is NOT a Qt issue.

                    JoeCFDJ Offline
                    JoeCFDJ Offline
                    JoeCFD
                    wrote on last edited by JoeCFD
                    #9

                    @SPlatten showEvent( QShowEvent * ) is the final spot to check if they are enabled or not. It is a good place for layout debugging. After debugging, simply remove it.

                    SPlattenS 1 Reply Last reply
                    0
                    • JoeCFDJ JoeCFD

                      @SPlatten showEvent( QShowEvent * ) is the final spot to check if they are enabled or not. It is a good place for layout debugging. After debugging, simply remove it.

                      SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #10

                      @JoeCFD , thanks for your effort and time, I've found the problem now and it wasn't to do with Qt, just my memory and me being stupid.

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved