http_request.cpp:177:21: No matching function for call to 'information' qmessagebox.h:217:34: candidate function not viable: no known conversion from 'Http_request *' to 'QWidget *' for 1st argument qmessagebox.h:207:16: candidate function not viable: no known conversion from 'Http_request *' to 'QWidget *' for 1st argument qmessagebox.h:185:27: candidate function not viable: no known conversion from 'Http_request *' to 'QWidget *' for 1st argument qmessagebox.h:210:16: candidate function not viable: no known conversion from 'Http_request *' to 'QWidget *' for 1st argument
时间: 2024-03-07 10:48:55 浏览: 137
根据错误提示,你正在从`Http_request`类中调用QMessageBox::information()函数,但是该函数需要一个QWidget类型的参数作为父窗口,而`Http_request`不是QWidget的子类。因此,你需要传递一个有效的QWidget对象作为父窗口,例如:
```
QMessageBox::information(this, "提示", "操作成功!", QMessageBox::Yes);
```
其中,this指针代表当前的QWidget对象,可以作为父窗口传递给QMessageBox::information()函数。如果你在其他的类中使用QMessageBox::information()函数,需要传递一个有效的QWidget对象作为父窗口。
相关问题
logwidget.cpp:46:9: error: no matching function for call to 'information' qmessagebox.h:185:27: note: candidate function not viable: requires at least 3 arguments, but 2 were provided qmessagebox.h:217:34: note: candidate function not viable: requires at least 4 arguments, but 2 were provided qmessagebox.h:207:16: note: candidate function not viable: requires at least 4 arguments, but 2 were provided qmessagebox.h:210:16: note: candidate function not viable: requires at least 4 arguments, but 2 were provided
这个错误表示在logwidget.cpp文件的第46行调用了一个名为'information'的函数,但是提供的参数数量不正确。根据错误信息,QMessageBox类中没有接受2个参数的名为'information'的函数。
QMessageBox类中的information函数至少需要3个参数。通常,它接受一个父对象、对话框标题和消息文本作为参数。请确保您在logwidget.cpp文件的第46行提供了这三个参数。
例如,您可以使用以下代码调用QMessageBox的information函数:
```cpp
QMessageBox::information(this, "标题", "消息文本");
```
请根据您的需求修改参数,并确保正确地调用了QMessageBox的information函数。重新编译您的代码,应该就能解决这个错误了。
你给的代码报错form_para.cpp:340:14: No matching function for call to 'swap' move.h:182:5: candidate function [with _Tp = QByteRef] not viable: expects an lvalue for 1st argument stl_bvector.h:114:3: candidate function not viable: no known conversion from 'QByteRef' to 'std::_Bit_reference' for 1st argument stl_bvector.h:122:3: candidate function not viable: no known conversion from 'QByteRef' to 'std::_Bit_reference' for 1st argument stl_bvector.h:130:3: candidate function not viable: no known conversion from 'QByteRef' to 'bool &' for 1st argument move.h:205:5: candidate template ignored: could not match '_Tp[_Nm]' against 'QByteRef' stl_pair.h:490:5: candidate template ignored: could not match 'pair<_T1, _T2>' against 'QByteRef' stl_pair.h:498:5: candidate template ignored: could not match 'pair<_T1, _T2>' against 'QByteRef' ... shared_ptr_base.h:1738:5: candidate template ignored: could not match '__weak_ptr<_Tp, _Lp>' against 'QByteRef' shared_ptr.h:490:5: candidate template ignored: could not match 'shared_ptr<_Tp>' against 'QByteRef' shared_ptr.h:611:5: candidate template ignored: could not match 'weak_ptr<_Tp>' against 'QByteRef'
非常抱歉,我的代码还是有误。QByteArray的swap函数确实只接受一个参数。如果要交换两个字节的高低位,可以使用以下代码:
```cpp
uint16_t value = 0x1234; // 待转换的uint16_t值
QByteArray bytes(reinterpret_cast<const char*>(&value), sizeof(value)); // 将uint16_t转换成QByteArray
char temp = bytes[0];
bytes[0] = bytes[1];
bytes[1] = temp;
QString str(bytes); // 将QByteArray转换成QString
```
在上述代码中,我们使用一个临时变量temp来交换QByteArray中的两个字节的高低位。最终,输出的字符串为:"4321"。
请注意,上述代码假定机器采用的是little-endian格式,即低地址存放的是值的低位字节。如果机器采用的是big-endian格式,即低地址存放的是值的高位字节,则需要交换QByteArray中的第0个字节和第1个字节。
阅读全文