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. [置顶] Unity2d引入新功能SpriteAtlas,Sprite新的图集方式

    孙广东  2017.8.3 http://blog.csdn.NET/u010019717 在Unity 2017.1.0f3中引入了 SpriteAtlas 官方文档:  https://docs. ...

  2. Winform开发常用控件之TreeView菜单导航和权限用法

    TreeView一个很棒的控件,我们在做WEB开发时常常犯困的一个东东.当然这里介绍winform里面的用法唠. 先介绍几个属性吧,CheckBoxes设置为true的话树形节点前面会出现checkb ...

  3. 解决sublime package control 出现There are no packages available for installation

    昨天在安装了一下Sublime Text 3,在安装插件的过程中出现了一些问题,现在记录一下,也给遇到同样问题的朋友一些帮助.在安装插件的时候,需要先安装一下Package Control. 安装Pa ...

  4. 如何在CentOS7上安装MySQL并实现远程访问

    传送门 本人乃学生小白一枚,近期在学习Linux,所以就简单记录一下~ 安装MySQL 首先,需要检查一下是否已经安装了MySQL : # rpm -qa | grep mysql 这时候没有任何输出 ...

  5. LOJ2316. 「NOIP2017」逛公园【DP】【最短路】【思维】

    LINK 思路 因为我想到的根本不是网上的普遍做法 所以常数出奇的大,而且做法极其暴力 可以形容是带优化的大模拟 进入正题: 首先一个很显然的思路是如果在合法的路径网络里面存在零环是有无数组解的 然后 ...

  6. java面试题7

    1.重载和重写的区别? 重载(Overload):(1)方法重载是让类以统一的方式处理不同类型数据的一种手段.多个同名函数同时存在,具有不同的参数个数/类型.重载Overloading是一个类中多态性 ...

  7. flask第二十八篇——HTML【1】table标签

    请关注公众号:自动化测试实战 以下内容参考:http://www.w3school.com.cn/tags/tag_table.asp <!DOCTYPE html> <html l ...

  8. emacs之配置speedbar

    安装sr-speedbar,这样的话,speedbar就内嵌到emacs里面了 emacsConfig/speedbar-setting.el (require 'sr-speedbar) (setq ...

  9. vim自定义配置之nerdTree

    vimConfig/plugin/nerdTree-setting.vim let g:NERDTree_title="[NERDTree]" nmap <F2> :N ...

  10. [转][html]大文件下载

    上面代码来自微软,用于下载大文件. 下面代码来自 http://www.cnblogs.com/smile-wei/p/4159213.html System.IO.Stream iStream = ...