0
我正在嘗試更改某個文本框消息。它會顯示我的輸出。QT創建我的表單對象,如何訪問該表單?
這是我在我的TcpClient()
#include "form2.h"....string recvMSG = "random";
QString s1 = QString::fromLocal8Bit(recvMSG.c_str());
182 ::窗體2 :: changeOutput(S1);
within my form2.h I have:
...
void Form2::changeOutput(QString &s)
{
output_box.setText(s1);
}
...
在我的主:
#include <qapplication.h>
#include "form2.h"
#include <string.h> /* for memset() */
#include <iostream>
#include <stdlib.h> /* for atoi() and exit() */
int main(int argc, char ** argv)
{
QApplication a(argc, argv);
Form2 w;
w.show();
a.connect(&a, SIGNAL(lastWindowClosed()), &a, SLOT(quit()));
return a.exec();
}
現在,我知道我應該打電話w.changeOutput(S1)。 但問題是,w沒有在我的TCPClient.cpp聲明...
QT爲我做了main()函數。我不知道如何解決這個問題。我想要從我的TCPClient.cpp中調用w.changeOutput(s1)。
這是我得到的錯誤。 TCPClient.cpp:182:錯誤:不能調用成員函數「虛擬無效窗體2 :: changeOutput(的std :: string)」沒有對象
感謝。