QObjectのQVectorがQVector<QWidget*> question_vector;
です。これらのウィジェットは質問です。 (私のアプリケーションはアンケートのようなものです)。QVectorに格納されたQObjectの側面にアクセスする
アンケートを作成するときに、コンボボックスの選択肢から質問タイプが選択され、質問クラス内に質問が作成され、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);
}
シングルは、ウィジェット、タイトル、titleEdit、コメント、commentsEditです。 ウィジェットの個々のコンポーネントのテキスト、commentsText QLineEditなどにアクセスするにはどうすればよいですか?
を行うことができました:http://stackoverflow.com/questions/41098139/mainpulating-a-qobject-created-from-a-button-press答えを得た。 exaclyあなたの問題は何ですか? –
それに、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