首页| 论坛| 消息

标题:【提问】谁能告诉我Qt处理二进制文件向数据库存储的思路吗?
作者:mzy
日期:2005-09-03 13:33
内容:

想把学习从一开始就放到Qt上,不知道Qt对windows下的数据库如:Access,SQL Server的访问是如何实现操作BLOB字段的.
上google搜索,只发现了在VC下有DAO ADO可以处理二进制数据流,在QT下用ODBC是怎么实现的呢? 各位大侠,路过看过,能给个思路吗?
谢谢.


#1 [XChinux 09-03 16:43]
QVariant QSqlResult::data ( int index )
Returns the data for field index in the current row as a QVariant. This function is only called if the result is in an active state and is positioned on a valid record and index is non-negative. Derived classes must reimplement this function and return the value of field index, or QVariant() if it cannot be determined.
不知道这个对你有用没用。没详细看过这方面的东西。应该是可以读写二进制数据的
#2 [yfy002 09-05 09:08]
QByteArray s = query.value(nameCol).toByteArray();//读取二进制对象

this is a example to write a pixmap into database
QByteArray pngImage;
QBuffer buffer(&pngImage);
buffer.open(QIODevice::WriteOnly);
upimage.save(&buffer, "PNG"); // writes upimage into bytes in PNG format
......
query.bindValue(7,pngImage,QSql::Binary);
#3 [mzy 11-15 22:27]
谢谢两位。程序完成后再请指教。

回复 发表
主题 版块