setText()
は、のラベルテキストを置き換えます。
#include <QWidget>
#include <QBoxLayout>
#include <QTextEdit>
#include <QPushButton>
#include <QLabel>
#include <QApplication>
#include <memory>
int main(int argc, char **argv)
{
QApplication app{argc, argv};
const auto w = std::make_unique<QWidget>();
const auto window = w.get();
const auto layout = new QVBoxLayout(window);
const auto text_1 = new QTextEdit(window);
layout->addWidget(text_1);
const auto text_2 = new QTextEdit(window);
layout->addWidget(text_2);
const auto button = new QPushButton("Push Me!", window);
layout->addWidget(button);
const auto label = new QLabel(window);
layout->addWidget(label);
QObject::connect(button, &QPushButton::pressed,
label, [=]() { label->setText(text_1->toPlainText() + "\n" + text_2->toPlainText()); });
window->show();
return app.exec();
}
あなたは 'UI-> label_az->のsetText(UI-> textEdit_ra1-> toPlainText()+ UI-> textEdit_ra2-> toPlainText())を捜していますか;'? – Mike
@Mike両方をlabel_azに表示します。どうすればいいのか教えてください。ありがとうございます – REZTO
@Mikeソリューションの問題点は何ですか?ほとんどの場合、セパレータを追加したいと思っています。 – cbuchart