我正在創建一個應用程序,並且在某些時候,用戶將創建某種來自/調查。創建時,用戶通過按下按鈕選擇各種問題類型等,並創建一個新的對象。調用從按鈕創建的QObject按
要創建新的部分,例如:
void CreateSurvey::question_section()
{
QLabel *sectionTitle = new QLabel();
sectionTitle->setText("New Section");
layout->addWidget(sectionTitle);
QLabel *titleLabel = new QLabel("Title");
QLineEdit *titleEdit = new QLineEdit("New Section");
QHBoxLayout *hLayout = new QHBoxLayout;
hLayout->addWidget(titleLabel);
hLayout->addWidget(titleEdit);
layout->addLayout(hLayout);
sectionCount++;
qDebug() << "sections: " << sectionCount;
}
當應用程序正在運行時,文本「TitleEdit」將通過用戶對節的標題進行編輯。說這個被稱爲3次,所以有3個部分。如何獲得爲每個部分的標題輸入的字符串?或者如何獲取爲特定部分輸入的字符串?
感謝
您需要存儲你感興趣的對象,否則你將不(僅僅)訪問他們。 –
我該怎麼做?在數組中? – Phauk
佈局包含您要添加的所有對象。您可以循環並提取所需的數據。 – bibi