编译成功,但是当我运行它时,终端给了我“分段错误(核心转储)”消息。我使用的编译器是 Ubuntu 上的 g++。
代码是:
#include <QApplication>
#include <QLabel>
#include <QLineEdit>
#include <QVBoxLayout>
#include <QWidget>
int main(int argc, char** argv){
QApplication app(argc, argv);
QWidget window;
QLabel *label = new QLabel;
QLineEdit *edit = new QLineEdit;
QObject::connect(edit, SIGNAL(textChanged(const QString&)), label, SLOT(setText(const QString&)));
QVBoxLayout *layout;
layout->addWidget(edit);
layout->addWidget(label);
window.setLayout(layout);
window.show();
return app.exec();
}