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

แชร์
ฝัง
  • เผยแพร่เมื่อ 15 ธ.ค. 2024

ความคิดเห็น • 2

  • @bennguyen1313
    @bennguyen1313 9 หลายเดือนก่อน

    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  9 หลายเดือนก่อน +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.