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. [solved]Manipulating multiple GUI-Objects at once
Forum Updated to NodeBB v4.3 + New Features

[solved]Manipulating multiple GUI-Objects at once

Scheduled Pinned Locked Moved General and Desktop
6 Posts 5 Posters 1.8k 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.
  • M Offline
    M Offline
    Mr.Floppy
    wrote on last edited by
    #1

    Hi there,

    I have an application with a bunch of lineEdits, that the user is supposed to fill with information.
    Then there is a shiny "Start the process"-Button.

    While the process is running it is pointless to enter new values.
    I want to make that as clear as possible, by blocking all Objects from human interference.

    Right now it is done like this:
    @ui->lineEdit_foo->setDisabled(true);
    ui->lineEdit_bar->setDisabled(true);
    ...@

    Is there a way to disable all of them in a less manual way?
    Something like:
    @for (MainWindow::allLineEdits) {
    disableThem(true);
    }@

    It is a small thing, but it would make my code a little more maintainable.

    Cheers,

    Schmaunz

    1 Reply Last reply
    0
    • A Offline
      A Offline
      andreyc
      wrote on last edited by
      #2

      I see several options

      Declare a QList or QVector of QLineEdit widgets and create them manually. Then you will be able to operate on the list of the line edits.

      Declare a QList or QVector of QLineEdit widgets. At the begging after ui->setupUi(this); put all ui->lineEdit_xxx to in the list of the line edit widgets. Then you will use that list to operate on all line edits.

      Create a signal disableAllEdits(bool). After ui->setupUi(this); connect all line edits slot setDisabled(bool) to the signal and emit disableAllEdits(true/false) when need to disable/enable the line edits.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        ScottR
        wrote on last edited by
        #3

        From the "Documentation:":http://qt-project.org/doc/qt-5/qwidget.html#enabled-prop "Disabling a widget implicitly disables all its children."

        1 Reply Last reply
        0
        • S Offline
          S Offline
          sledgehammer_999
          wrote on last edited by
          #4

          Put all your lineedits in the same container/box. Then disable the container when the user clicks the button.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            Mr.Floppy
            wrote on last edited by
            #5

            Sorry for the late answer and thanks for your replies.
            Disabling the container around the lineEdits works just fine :)

            1 Reply Last reply
            0
            • JeroentjehomeJ Offline
              JeroentjehomeJ Offline
              Jeroentjehome
              wrote on last edited by
              #6

              Please, place [SOLVED] in front of your first post if the answer was given. Saves us from reading!

              Greetz, Jeroen

              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