我只是用Qt弄溼我的腳,我試圖從QlineEdit中拉出字符串,並在單擊按鈕後將它附加到QTextBrowser(爲了簡單/錯誤檢查,我我只是把它附加在此刻的單詞)。在QT中設置新的公共信號後出現Seg故障
該程序運行,並在屏幕上顯示GUI,但每當我點擊按鈕,我的程序段故障。
這裏是我的代碼,我砍掉了很多了,這是不必要的:
部首:
#ifndef TCD2_GUI_H
#define TCD2_GUI_H
//bunch of includes
class TCD2_GUI : public QWidget
{
Q_OBJECT
public:
TCD2_GUI(QWidget *window = 0);
//bunch of other members
QLineEdit *a1_1;
QTextBrowser *stdoutput;
public slots:
void applySettings(void);
private:
};
#endif // TCD2_GUI_H
,這裏是其中的導致故障的cpp的代碼片段
QTextBrowser *stdoutput = new QTextBrowser();
stdoutput->append("Welcome!");
QObject::connect(apply, SIGNAL(clicked()), this, SLOT(applySettings()));
//------------------------------------------------------Standard Output END
//layout things
}
void TCD2_GUI::applySettings()
{
stdoutput->append("appended");
}
謝謝你,也對。 – 2011-02-07 01:38:28