我一直在搜索所有的Stack Overflow,但似乎没有一个例子可以工作。
我想向服务器发出//reader.h
signals:
void updateData(quint16 fw, QString serial, quint16 *calibration);
//reader.cpp
...
{
quint16 calibration[8];
quint16 fw;
QString serialNumber;
readData(&fw, &serialNumber, calibration);
// Declaration: void Reader::readData(quint16 *fw, QString *serial, quint16 *calibration)
emit updateData(fw, serialNumber, calibration); // In this function all parameters are assigned correctly
}
//mainwindow.h
public slots:
void updateData(quint16 fw, QString serialNumber, quint16 *calibration);
//mainwindow.cpp
void MainWindow::updateData(quint16 fw, QString serialNumber, quint16 *calibration)
{
ui->lineEditFW->setText(QString::number(fw)); // correct
ui->lineEditSerialNumber->setText(serialNumber); // correct
ui->spinBoxReg1->setValue(calibration[0]); // incorrect!
ui->spinBoxReg2->setValue(calibration[1]); // ..array calibration
ui->spinBoxReg3->setValue(calibration[2]); // ..is filled with
ui->spinBoxReg4->setValue(calibration[3]); // ..random data!
ui->spinBoxReg5->setValue(calibration[4]);
ui->spinBoxReg6->setValue(calibration[5]);
ui->spinBoxReg7->setValue(calibration[6]);
ui->spinBoxReg8->setValue(calibration[7]);
}
//...
init()
{
// other connection of thread and reader object
//...
connect(reader, SIGNAL(updateData(quint16, QString, quint16 *)), this, SLOT(updateData(quint16, QString, quint16 *)));
//...
reader->moveToThread(readerThread);
readerThread->start();
}
请求,其他标头信息和参数如下所示
POST
如何执行{"parameter1": "blabla", "parameter_2": "haha"}
请求并将响应保存在变量中?
无论我在哪里,我似乎找不到工作代码,我经常在VB.net中遇到错误。