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. Disabling UI through children issue
Forum Updated to NodeBB v4.3 + New Features

Disabling UI through children issue

Scheduled Pinned Locked Moved Solved General and Desktop
8 Posts 2 Posters 689 Views
  • 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.
  • J Offline
    J Offline
    JSher
    wrote on last edited by
    #1

    Hello,

    I have the code:

    for(auto *widget : this->findChildren<QWidget *>())
     {
               if((widget->objectName() != "progressBar") and (widget->objectName() != "loggingArea")){
                        widget->setEnabled(false);
               }
     }
    

    This still greys out the whole UI(I checked the names are correct.

    Then I tried:

    for(auto *widget : this->findChildren<QWidget *>())
            {
               widget->setEnabled(false);
            }
            ui->progressBar->setEnabled(true);
            ui->loggingArea->setEnabled(true);
    

    This still has progressBar and loggingArea greyed.

    This is in a button click method.

    What am I doing wrong?

    Thanks,
    --James

    1 Reply Last reply
    0
    • B Offline
      B Offline
      Bonnie
      wrote on last edited by
      #2

      Seems progressBar and loggingArea are not the direct children of this?
      If their parent widget is disabled, they'll also be grey even if they are not disabled.

      1 Reply Last reply
      1
      • J Offline
        J Offline
        JSher
        wrote on last edited by
        #3

        @Bonnie
        hmm they are printed out here for(auto *widget : this->findChildren<QWidget *>()) if I do qDebug() << widget->objectName();

        Would that not make them a direct child of this?

        Thanks,
        --James

        B 1 Reply Last reply
        0
        • J JSher

          @Bonnie
          hmm they are printed out here for(auto *widget : this->findChildren<QWidget *>()) if I do qDebug() << widget->objectName();

          Would that not make them a direct child of this?

          Thanks,
          --James

          B Offline
          B Offline
          Bonnie
          wrote on last edited by Bonnie
          #4

          @JSher

          QList<T> QObject::findChildren(const QString &name = QString(), Qt::FindChildOptions options = Qt::FindChildrenRecursively) const

          So the default option for findChildren is to find recursively. They might not be direct children.
          You are using ui, you should know that whether their parent widget is this or not?

          1 Reply Last reply
          0
          • J Offline
            J Offline
            JSher
            wrote on last edited by
            #5

            @Bonnie

            I am assuming it is grabbing the layout as well then and disabling it as well and that is why I cannot just enable that widget as its parent is disabled. Its built through the designer so I never looked TBH, was just looking for a fast way to disable all my widgets except 2.

            Thanks,:)

            1 Reply Last reply
            0
            • J Offline
              J Offline
              JSher
              wrote on last edited by
              #6

              @Bonnie

              I did more testing. if I do this:

              if((widget->objectName() != "centralwidget") and (widget->objectName() != "loggingArea") ){
                          widget->setEnabled(false);
                      }
              

              this still greys the whole UI.

              Also:

              ui->loggingArea->parent()->parent()->objectName()
              

              Is MainWindow which is this.

              Any ideas?

              Thanks,
              --James

              B 1 Reply Last reply
              0
              • J JSher

                @Bonnie

                I did more testing. if I do this:

                if((widget->objectName() != "centralwidget") and (widget->objectName() != "loggingArea") ){
                            widget->setEnabled(false);
                        }
                

                this still greys the whole UI.

                Also:

                ui->loggingArea->parent()->parent()->objectName()
                

                Is MainWindow which is this.

                Any ideas?

                Thanks,
                --James

                B Offline
                B Offline
                Bonnie
                wrote on last edited by Bonnie
                #7

                @JSher What is a loggingArea?
                If it is a scroll area, although itself is not disabled, but the viewport and scroll bars in it will be disabled.
                And any widget that has child widgets also have the same problem.

                1 Reply Last reply
                0
                • J Offline
                  J Offline
                  JSher
                  wrote on last edited by
                  #8

                  Ahh, basically its a terrible way to disable then, ill have to just do them all individually:)

                  Thanks,
                  --James

                  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