Introduction to Qt Widgets (Part 15) - Layout in Qt Designer

Поділитися
Вставка
  • Опубліковано 20 сер 2024

КОМЕНТАРІ • 2

  • @bennguyen1313
    @bennguyen1313 5 місяців тому

    Within Qt Designer, can you make an array of Checkboxes?
    I know you can create then access via code,
    QCheckBox checkboxes[10];
    for (int i = 0; i < 10; ++i) {
    checkboxes[i].setObjectName(QString("ck%1").arg(i + 1));
    checkboxes[i].setText(QString("Checkbox %1").arg(i + 1));
    }
    But can you drag a checkbox into Designer and tell it this will be number 5 of 10?

    • @KDABtv
      @KDABtv  5 місяців тому +1

      Hi, Jesper speaking here:
      I'm afraid that is not possible. Your option would be to drag the amount of checkboxes you want in.
      But if you want it more dynamic, as I expect you would, then what I'd do is to simply drag in an empty QWidget in the place you want them, and then from C++ populate that widget with the amount of children you want.