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. gradle 代理设置

    可以对gradle全局设置变量,也可以针对单个项目进行配置. 只需要在.gradle目录下创建一个gradle.properties文件,文件中按照如下格式添加代理配置 systemProp.http ...

  2. 《DSP using MATLAB》Problem 2.9

    代码: %% ------------------------------------------------------------------------ %% Output Info about ...

  3. 《DSP using MATLAB》Problem 2.8

    1.代码: 从MATLAB官方网上下载的. %*************************************************************************% %A ...

  4. IE9 下面, XMLHttpRequest 是不支持跨域请求的解决方法

    在 IE9 下面, XMLHttpRequest 是不支持跨域请求的. IE10 的 XMLHttpRequest 支持跨域, 而 IE8, IE9 需要使用 XDomainRequest 来实现跨域 ...

  5. linux 下 ifcfg-eth0 配置/CentOS_minimal安装和开发环境部署

    CentOS_minimal安装和开发环境部署:http://www.th7.cn/system/lin/201305/39002.shtml 网络接口配置文件 [root@localhost ~]# ...

  6. [C++ Primer] 第6章: 函数

    参数传递 const形参和实参: 顶层const作用于对象本身, 和其他初始化过程一样, 当用实参初始化形参时会忽略掉顶层const, 换句话说, 形参顶层const被忽略掉了, 当形参有顶层cons ...

  7. MySQL分段统计SQL写法 与 Mybatis 异常 java.math.BigDecimal cannot be cast to java.lang.Integer

    mysql> select end) as '<60', end) as '60~69', end) as '70~79', end) as '80~89', end) as '>= ...

  8. 黄聪:Windows 64位系统中安装Android SDK“系统找不到指定的文件Java.exe”解决方法

    明明已经在64位window7中安装好了64位版本的jdk,为什么android SDK安装程序却识别不到jdk呢?先看看报错: Java SE Development Kit (JDK) not f ...

  9. JavaWeb的过滤器Filter

    Filter的作用是在请求到达web资源(HTML.css.Servlet.Jsp)之前拦截,做一个预处理. 创建一个类实现Filter接口,在web.xml中对文件进行配置 <filter&g ...

  10. Java 字符串拼接 StringBuilder() StringBuffer

            字符串拼接 普通方式 public class StringDemo2 { public static void main(String[] args) { // 表示获取从1970- ...