[solved]Manipulating multiple GUI-Objects at once

  • 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:

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

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



  • 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.

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

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

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

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

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.