Qt Read and Write Csv File
This page discusses various available options for working with csv documents in your Qt application. Please also read the general considerations outlined on the Handling Document Formats page.
Using QxtCsvModel
intro
The QxtCsvModel class provides a QAbstractTableModel for CSV Files. This is perhaps the easiest way possible to read and write csv files without having to parse the csv format to something qt can understand. It's as simple as using one line of code, for example the following reads the csv file:
csvmodel->setSource(fileName);
Building libqxt
QxtCsvModel is a part of libqxt so just to use QxtCsvModel you'll need to build this library. It won't be that hard. instructions(指令) are all provided. However, the download link that they provide in their main page does not support Qt 5 as of this writing (23 April 2013). You'll need to go to the downloads page, select the "branches" tab and download the zip file of the master branch.
A novice-friendly(新手朋友) step-by-step guide to building and getting libqxt to work can be found here. The following example will be using the build as done in that guide.
Example: Mini csv Program
Mini csv program is built with Qt 5.0.2 MinGW, but should probably work with Qt 4. Download from here . The only thing you would need to do to get it working is fix the links to the dynamic library. I built it in C:/Qt/libqxt-libqxt-Qt5/ so I directed it there. Below is a snipet of the project file:
win32:CONFIG (release, debug|release): LIBS ''= -LC:/Qt/libqxt-Qt5/lib/ -lqxtcore
else:win32:CONFIG (debug, debug|release): LIBS''= -LC:/Qt/libqxt-Qt5/lib/ -lqxtcore
INCLUDEPATH ''= C:/Qt/libqxt-Qt5/src/core
DEPENDPATH''= C:/Qt/libqxt-Qt5/src/core
Well, you're also suppose to add the following lines to your qmake project file:
CONFIG ''= qxt
QXT''= core gui
…but it doesn't seem to make much of a difference here… or any of the examples I've tried…
I can now call the class like so:
#include <QxtCsvModel>
The functionality provided is very very basic. If you wish to probe deeper to what this class can do, check the QxtCsvModel documentation .
CSV reader from QtSimplify(Read CSV Only)
Reference
Qt Read and Write Csv File的更多相关文章
- ogr2ogr: Export Well Known Text (WKT) for one feature to a CSV file
Perhaps you’re looking for this? ogr2ogr -f “CSV” “E:\4_GIS\NorthArkCartoData\UnitedStates\MO_wkt” “ ...
- C# - CSV file reader
// ------------------------------------------------------------------------------------------------- ...
- SQL SERVER – Import CSV File Into SQL Server Using Bulk Insert – Load Comma Delimited File Into SQL Server
CSV stands for Comma Separated Values, sometimes also called Comma Delimited Values. Create TestTabl ...
- [PowerShell Utils] Create a list of virtual machines based on configuration read from a CSV file in Hyper-V
Hello everyone, this is the third post of the series. . Background =============== In my solution, ...
- Python: Write UTF-8 characters to csv file
To use codecs, we can write UTF-8 characters into csv file import codecs with open('ExcelUtf8.csv', ...
- save tracking results into csv file for oxuva long-term tracking dataset (from txt to csv)
save tracking results into csv file for oxuva long-term tracking dataset (from txt to csv) 2019-10-2 ...
- Powercli随笔 - PowerCLI script to sequentially Storage vMotion VMs from a CSV File
PowerCLI script to sequentially Storage vMotion VMs from a CSV File This is a PowerCLI script that I ...
- Csharp--Read Csv file to DataTable
在网上找的资料都不怎么好使,许多代码一看就知道根本没有考虑全面. 最后找到一个好用的,在codeproject上,这位老兄写成了一个framework,太重了. http://www.codeproj ...
- redmine export long csv file failed: 502 proxy error
After modified the file \apps\redmine\conf\httpd-vhosts.conf: <VirtualHost *:8080> ServerName ...
随机推荐
- jenkins执行shell命令,有时会提示“Command not found”
这个问题其实就是环境变量没有配准确 (1)检查你在Jenkins中设置的maven是否准确,可以通过[new job]按钮查看新建job中是否有maven选项,没有就是你配置的不准确 如果你下载的插件 ...
- Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.threadpool.ThreadPool
springboot中遇到的, 将guava添加到项目中即可.(当时添加的是guava 18)
- fusionjs uber开源的通用web插件化开发框架
fusionjs uber开源的web 插件化开发框架 核心特性: 基于插件的开发,依赖注入开发 开箱即用的服务器端渲染,构建结果拆分,模块热加载 Tree-shaking 支持 集成的插件 redu ...
- 使用UltraISO制作U盘启动
下面给你提供是的一个万能的制作系统U盘的方法,用这个U盘你可以加载任何你想要的系统,即使是Linux系统都是可以,你需要做的就是下载安装软件,下载一个系统安装光盘的镜像文件,然后用软件导入到U盘就可以 ...
- java设计模式--七大原则
2016-05-14 20:45:38 设计模式到底是五大.六大还是七大,一直傻傻分不清楚,网上总是有说那些原则可以归为一个,我纠结了半天,突然发现自己是舍本逐末了,只要清楚这些原则的设计思想,其他的 ...
- IAR 9+ 编译 TI CC2541 出现 Segment ISTACK (size: 0xc0 align: 0) is too long for segment definition.
IAR 9+ 编译 TI CC2541 出现 Segment ISTACK (size: 0xc0 align: 0) is too long for segment definition. Segm ...
- iSCSI 协议
iSCSI 协议 iSCSI协议结构 如同任何一个协议一样,iSCSI也有一个清晰的层次结构,根据OSI模型,iSCSI的协议栈自顶向下一共可以分为五层,如图所示: SCSI层:根据应用发出的请求建立 ...
- C++ 函数特性_函数重载
函数重载 在相同作用域内 用同一函数名定义的多个函数: 参数个数和参数类型不同 int getMax(int x,int y,int z) // 函数名相同都是 getMax() { // to do ...
- 使用maven构建基本的web项目结构
由于当前公司在组织进行项目基本结构的整理,将以前通过eclipse/ ant 方式构建的项目向maven上迁移,于是便进行maven项目方面的调研. 对于maven项目,基本的结构已经在标准文件中: ...
- 第十九课 golang中的下划线
在 Golang 里, _ (下划线)是个特殊的标识符. 用在 import 在导包的时候,常见这个用法: 1 2 import _ "net/http/pprof" import ...