나는 QObject의 QVector가 QVector<QWidget*> question_vector;
입니다. 위젯은 질문입니다. (신청서는 설문지와 같습니다.)QVector에 저장된 QObject의 측면에 액세스하기
질문지를 만들 때 comboBox의 선택에서 질문 유형이 선택되고 질문 클래스 내에서 질문이 만들어지고 QVector에 저장됩니다.
void CreateSurvey::comboBox_selection(const QString &arg1)
{
if(arg1 == "Single Line Text")
{
Question *singleLineText = new Question("Single Line Text");
surveyLayout->addWidget(singleLineText);
question_vector.append(singleLineText);
qDebug() << "Number of items: "<< question_vector.size();
} ...
}
void Question::create_singleLineEdit()
{
QVBoxLayout *vLayout = new QVBoxLayout;
QLabel *titleLabel = new QLabel("Title");
vLayout->addWidget(titleLabel);
QLineEdit *inputText = new QLineEdit;
vLayout->addWidget(inputText);
QLabel *commentsLabel = new QLabel("Comments");
vLayout->addWidget(commentsLabel);
QLineEdit *commentsText = new QLineEdit;
vLayout->addWidget(commentsText);
ui->frame->setLayout(vLayout);
}
SingleLineEdit
위젯, 제목, titleEdit, 의견, commentsEdit입니다. 위젯의 개별 구성 요소에있는 텍스트 인 commentsText QLineEdit에 어떻게 액세스합니까?
을 할 다음 수 있었다 : http://stackoverflow.com/questions/41098139/mainpulating-a-qobject-created-from-a-button-press 대답을 얻었다. 그대의 문제는 무엇인가? –
그 중 하나는 line_edit_vector [index] -> text(); QVector의 텍스트를 가져 오는 중 line_edit_vector; 그래서 지금 전진 해 QVector를 가졌습니다 question_vector; 위젯의 다른 유형이 lineedits보다는 추가되기 때문에 question_vector [3]에있는 객체 내에 lineedit이 있으면 그 정보를 어떻게 얻을 수 있습니까? question_vector [3] -> commentsText-> text(); does not work –
Phauk