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)

not to access

Reference

qtwiki

github

stackoverflow

wikipedia


Qt Read and Write Csv File的更多相关文章

  1. 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” “ ...

  2. C# - CSV file reader

    // ------------------------------------------------------------------------------------------------- ...

  3. 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 ...

  4. [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, ...

  5. 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', ...

  6. 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 ...

  7. 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 ...

  8. Csharp--Read Csv file to DataTable

    在网上找的资料都不怎么好使,许多代码一看就知道根本没有考虑全面. 最后找到一个好用的,在codeproject上,这位老兄写成了一个framework,太重了. http://www.codeproj ...

  9. redmine export long csv file failed: 502 proxy error

    After modified the file \apps\redmine\conf\httpd-vhosts.conf: <VirtualHost *:8080> ServerName ...

随机推荐

  1. Winform开发常用控件之DataGridView的简单数据绑定——自动绑定

    DataGridView控件可谓是Winform开发的重点控件,对于数据的呈现和操作非常方便,DataGridView可谓是既简单又复杂.简单在于其已经集成了很多方法,复杂在于可以使用其实现复杂的数据 ...

  2. I.MX6 Linux 3.0.35 SD boot

    /********************************************************************************* * I.MX6 Linux 3.0 ...

  3. BZOJ5312: 冒险【线段树】【位运算】

    Description Kaiser终于成为冒险协会的一员,这次冒险协会派他去冒险,他来到一处古墓,却被大门上的守护神挡住了去路,守护神给出了一个问题, 只有答对了问题才能进入,守护神给出了一个自然数 ...

  4. 都是用 DllImport?有没有考虑过自己写一个 extern 方法?

    你做 .NET 开发的时候,一定用过 DllImport 这个特性吧,这货是用于 P/Invoke (Platform Invoke, 平台调用) 的.这种 DllImport 标记的方法都带有一个 ...

  5. LDAP基本概念

    LDAP(Lightweight Directory Access Protocol)是一种基于计算模型的客户机/服务器X.500目录服务访问协议.LDAP是从X.500目录访问协议的基础上发展过来的 ...

  6. Oracle SYS_CONTEXT用法

    1. USERENV(OPTION) 返回当前的会话信息. OPTION='ISDBA'若当前是DBA角色,则为TRUE,否则FALSE. OPTION='LANGUAGE'返回数据库的字符集. OP ...

  7. CSS背景图像的简单响应

    本文设有很多,最理想的解决方案,响应图像只是其中之一.我们建议您查看不同的方法,然后再选择一个特定的响应图像解决方案,包括这两个:如何避免重复下载响应图像中选择响应图像解决方案. 大家都在谈论的的sr ...

  8. String..lastIndexOf(".") 返回-1的思考

    String s = tableName.substring(tableName.lastIndexOf(".") + 1); 如果有tableName有'.',那么返回正确的截取 ...

  9. python 面向对象 初始化

    参考学习: http://www.runoob.com/python/python-object.html 其中 函数里面 self.name 就是用 初始化的 name Employe.empCou ...

  10. 文件读取错误UnicodeDecodeError: 'utf-8' codec can't decode byte 0x92 in position 884: invalid start byte

    参考: https://segmentfault.com/q/1010000004268196/a-1020000004269556 ubuntu下Python3使用open('filename', ...