QString::arg: Argument missing: UPDATE test217 SET ????? = 25% WHERE ??????='TP36', 258
时间: 2024-06-15 13:06:17 浏览: 16
QString::arg是Qt框架中的一个函数,用于格式化字符串。它的作用是将字符串中的占位符替换为实际的值。在你提供的代码中,出现了两个问号的占位符,分别对应两个参数。根据代码的语境,我们可以猜测第一个问号对应的是要更新的字段名,第二个问号对应的是WHERE条件。
所以,你需要将代码中的两个问号替换为实际的字段名和WHERE条件。例如,如果要更新字段名为"column_name"的值为25%,WHERE条件为"column_name='TP36'",那么代码可以修改为:
QString query = "UPDATE test217 SET column_name = 25% WHERE column_name='TP36'";
QString formattedQuery = query.arg("column_name").arg("TP36");
这样,formattedQuery就是替换了占位符的最终查询语句。
相关问题
QString::arg: Argument missing: UPDATE test217 SET ????? = '25%' WHERE ??????='TP36';, 65181
QString::arg是Qt框架中的一个函数,用于格式化字符串。它的作用是将一个参数插入到字符串中的占位符位置。在你提供的例子中,字符串"UPDATE test217 SET ????? = '25%' WHERE ??????='TP36';"中包含了两个占位符"?????"和"??????", 但是缺少了对应的参数。
为了正确使用QString::arg函数,你需要提供两个参数,分别对应两个占位符。例如,你可以这样使用:
QString query = "UPDATE test217 SET %1 = '25%' WHERE %2='TP36';";
QString columnName = "column_name";
QString condition = "condition_column";
QString formattedQuery = query.arg(columnName).arg(condition);
这样,formattedQuery的值将会是"UPDATE test217 SET column_name = '25%' WHERE condition_column='TP36';"。
QString::arg: Argument missing的报错解决办法
"QString::arg: Argument missing"的报错是由于在使用QString的arg方法时,参数缺失导致的。解决这个问题的方法有两种:
1. 检查代码中arg方法的参数是否完整,确保每个占位符都有对应的参数传入。
2. 使用arg的多参数重载方法,将所有参数一次性传入,避免链式调用arg方法时出现参数缺失的情况。
例如,使用多参数重载方法可以这样写:
```
QString sxy = QString("(x=%1y=%2)").arg(pt.x).arg(pt.y);sNum = QString("%1(%2)").arg(sxy).arg(sName).toStdString();
sMacPos = QString("%1,%2").arg(pt.x).arg(pt.y).toStdString();
```
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)