大家好,我使用 python 向 qt 发送字符串,但我不知道如何在标签上显示字符串,谁能帮助我???我的 mainwindow.cpp 是
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QTimer *timer=new QTimer(this);
connect(timer,SIGNAL(timeout()),this,SLOT(showTime()));
timer->start();
tcpServer.listen(QHostAddress::Any,42207);
//QByteArray Msg= tcpSocket->readAll();
readMessage();
}
void MainWindow::showTime()
{
QTime time=QTime::currentTime();
QString time_text=time.toString("hh:mm:ss");
ui->Digital_clock->setText(time_text);
QDateTime dateTime = QDateTime::currentDateTime();
QString datetimetext=dateTime.toString();
ui->date->setText(datetimetext);
}
void MainWindow::readMessage()
{
ui->receivedata_2->setText("no connection yet");
if(!tcpServer.listen(QHostAddress::Any,42207))
ui->receivedata_2->setText("waitting!");
//QByteArray Msg= tcpSocket->readAll();
}
每次我尝试放置 socket->readall() 时它都会在我调试时崩溃