QString.toInt() doesnt work - Error: invalid operands to binary expression ('const char *' and 'const char [14]')
QString.toInt() doesnt work - Error: invalid operands to binary expression ('const char *' and 'const char [14]')
我有这个代码:
QString carda = "000123";
QString queryStringAnet("SELECT * FROM [records] WHERE ([user]='" + carda.toInt() + "' AND [apl]='"+apl+"' AND [tasktype]='"+taskType+"' AND [taskkind]='"+taskKind+"' AND [timestamp]='"+timestamp+"')");
以及当我使用 carda.toInt() 时从 QString 到 Int 的转换我有这个错误:
error: invalid operands to binary expression ('const char *' and
'const char [14]')
和警告:
warning: adding 'int' to a string does not append to the string
use array indexing to silence this warning
我不明白为什么 QString.toInt() 不会工作...有什么想法吗?
I dont understand why QString.toInt() wont be working... any idea?
问题是在 qt 中你不能将字符串和数字连接在一起...
实际上你甚至不需要将字符串 carda 转换为整数,因为那是一个 QString
而只是做:
QString queryStringAnet("SELECT * FROM [records] WHERE ([user]='" + carda + "' AND [apl]='"+apl+"' AND [tasktype]='"+taskType+"' AND [taskkind]='"+taskKind+"' AND [timestamp]='"+timestamp+"')");
我有这个代码:
QString carda = "000123";
QString queryStringAnet("SELECT * FROM [records] WHERE ([user]='" + carda.toInt() + "' AND [apl]='"+apl+"' AND [tasktype]='"+taskType+"' AND [taskkind]='"+taskKind+"' AND [timestamp]='"+timestamp+"')");
以及当我使用 carda.toInt() 时从 QString 到 Int 的转换我有这个错误:
error: invalid operands to binary expression ('const char *' and 'const char [14]')
和警告:
warning: adding 'int' to a string does not append to the string
use array indexing to silence this warning
我不明白为什么 QString.toInt() 不会工作...有什么想法吗?
I dont understand why QString.toInt() wont be working... any idea?
问题是在 qt 中你不能将字符串和数字连接在一起...
实际上你甚至不需要将字符串 carda 转换为整数,因为那是一个 QString
而只是做:
QString queryStringAnet("SELECT * FROM [records] WHERE ([user]='" + carda + "' AND [apl]='"+apl+"' AND [tasktype]='"+taskType+"' AND [taskkind]='"+taskKind+"' AND [timestamp]='"+timestamp+"')");