【发布时间】:2014-10-28 01:23:38
【问题描述】:
我需要从数据库 (MariaDB) 中检索一个 INT 并将其放入使用 GTK3 制作的列表中。
当我尝试将变量从 MariaDB 传递到 GTK3 时,编译器会抛出以下错误:
cannot pass objects of non-trivially-copyable type ‘const class mysqlpp::String’ through ‘...’
(这发生在函数void item(string nombre)中,在括号内的行中,在for循环中)
所以,我要感谢任何可以告诉我解决此问题的方法的人。 谢谢你的回答。
代码如下:
void item(string nombre)
{
Connection con;
con.connect("", server, user, pass);
con.select_db(db);
string consulta = nombre;
Query pedido = con.query(consulta);
StoreQueryResult resp = pedido.store();
Row fila;
for (i=0; i<resp.num_rows(); i++)
/*THE PROBLEM IS HERE*/
{
gtk_list_store_append(GTK_LIST_STORE(list_store), &list_iterator);
gtk_list_store_set(GTK_LIST_STORE(list_store), &list_iterator, 0, resp[i][1], 1, resp[i][2], 2, resp[i][1],-1);
}
con.disconnect();
}
【问题讨论】:
-
第 70 行是哪一行?
-
我知道它在里面,但你真的希望我们从源文件的顶部计数第 70 行吗?习惯上在发生错误的那一行添加注释,这样我们就不必自己去寻找它了。
-
@cdhowie 它在 void item(string nombre) 的括号内 for (i=0; i
-
70 和 71 是该部分括号内的行
-
使用 SOF 一段时间后,感觉对它的工作方式更加熟悉了,所以我改了问题,让它更清楚。
标签: c++ mysql variables type-conversion gtk3