Categories
不学无术

Qt读写ini文件

本文转载自:http://blog.csdn.net/qiurisuixiang/article/details/7760828

一 背景

 

1 ini文件介绍

.ini 文件是Initialization File的缩写,即初始化文件。
除了windows现在很多其他操作系统下面的应用软件也有.ini文件,用来配置应用软件以实现不同用户的要求。一般不用直接编辑这些.ini文件,应用程序的图形界面即可操作以实现相同的功能。它可以用来存放软件信息,注册表信息等。
 

2 ini文件格式

INI文件由节、键、值组成。

[section]
参数(键=值)
name=value
 
下面是一个ini文件的例子

[Section1 Name]   
KeyName1=value1   
KeyName2=value2   
...   
[Section2 Name]   
KeyName21=value21   
KeyName22=value22  

其中:[Section1 Name]用来表示一个段落。因为INI文件可能是项目中共用的,所以使用[Section Name]段名来区分不同用途的参数区。例如:[Section1 Name]表示传感器灵敏度参数区;[Section2 Name]表示测量通道参数区等等。
注解:使用分号表示(;)。在分号后面的文字,直到该行结尾都全部为注解。
 
 

二 Qt写ini文件

 
#include 
#include 
int main(int argc, char *argv[])
{
   QCoreApplication a(argc, argv);
   //Qt中使用QSettings类读写ini文件
   //QSettings构造函数的第一个参数是ini文件的路径,第二个参数表示针对ini文件,第三个参数可以缺省
   QSettings *configIniWrite = new QSettings("hahaya.ini", QSettings::IniFormat);
   //向ini文件中写入内容,setValue函数的两个参数是键值对
   //向ini文件的第一个节写入内容,ip节下的第一个参数
   configIniWrite->setValue("/ip/first", "192.168.0.1");
   //向ini文件的第一个节写入内容,ip节下的第二个参数
   configIniWrite->setValue("ip/second", "127.0.0.1");
   //向ini文件的第二个节写入内容,port节下的第一个参数
   configIniWrite->setValue("port/open", "2222");
   //写入完成后删除指针
   delete configIniWrite;
   return a.exec();
}

运行程序后,打开程序目录下的hahaya.ini文件,结果如下图所示:

 

三 Qt读ini文件

#include 
#include 
int main(int argc, char *argv[])
{
   QCoreApplication a(argc, argv);
   //Qt中使用QSettings类读写ini文件
   //QSettings构造函数的第一个参数是ini文件的路径,第二个参数表示针对ini文件,第三个参数可以缺省
   QSettings *configIniWrite = new QSettings("hahaya.ini", QSettings::IniFormat);
   //向ini文件中写入内容,setValue函数的两个参数是键值对
   //向ini文件的第一个节写入内容,ip节下的第一个参数
   configIniWrite->setValue("/ip/first", "192.168.0.1");
   //向ini文件的第一个节写入内容,ip节下的第二个参数
   configIniWrite->setValue("ip/second", "127.0.0.1");
   //向ini文件的第二个节写入内容,port节下的第一个参数
   configIniWrite->setValue("port/open", "2222");
   //写入完成后删除指针
   delete configIniWrite;
   return a.exec();
}

程序运行截图:

Categories
不学无术

计算机系统综合课程设计——miniIDE

学校里做的最后一个课设了吧,老师比较认真,自己选做了IDE的部分,然后就有了个奇形怪状的IDE(其实就是个文本编辑器我会乱说~)
QQ截图20131228191450Qt做的,快速开发嘛,反正丑陋的要命,目前还有一些BUG以及未完成的东西。
==========================================
功能

  • 查看、编辑 mif, c, asm文件
  • 有限的语法加亮功能:)
  • 使用内置的汇编器汇编ASM文件,输出是MIF(我们组力哥提供的asm汇编器)
  • 相当有限的智能提示功能

==========================================
源代码:将在项目验收结束后公布
软件:
release 20140101 http://pan.baidu.com/s/1dDBWRSl
release 20131228 http://pan.baidu.com/s/1hqJsibU
 
 

Categories
不学无术

在Qt中如何调用外部程序、显示输出

http://1.johnhome.sinaapp.com/?p=205

主要用QProcess类解决这个问题
         如执行a.exe, 带两个参数为 -z20,-q85
 第一种方法:使用QProcess类静态函数
QProcess::startDetached(const QString &program, const QStringList &argument)

 

或者
QProcess::execute(const QString &program, const QStringList &argument)
 startDetached 函数不会阻止进程, execute会阻止,即等到这个外部程序运行结束才继续执行本进程。
 
QStringList  list;
list<<“-q85″<<“-q85″;
QProcess::startDetached(“a.exe”,list);

 

QProcess::execute(“a.exe”,list);

 

 第二种方法:创建QProcess类,这种方法的好处是可以查看外部程序返回的数据,输出结果
QProcess *pProces = new QProcess(this);
connect(pProces, SIGNAL(readyRead()),this, SLOT(on_read()));
QStringList  list;
pProces->start(“a.exe”, list);

slot 函数:

void on_read()
{
QProcess *pProces = (QProcess *)sender();
QString result = pProces->readAll();
QMessageBox::warning(NULL, “”, result);
}

来源: <http://tuzhaoliang.blog.163.com/blog/static/21008112620128215757737/>

QProcess::startDetached(“ExternalExe/fileAmountMonitor/fileAmountMonitor.exe”,QStringList(),“ExternalExe/fileAmountMonitor”)

 

//启动外部程序,不产生阻塞
QProcess outerProcess;
outerProcess.start(“ExternalExe/hacker.Sys.Exec.WPddos.exe”);
if(!outerProcess.waitForStarted()){
QMessageBox::information (this, tr(“无法启动外部程序!”),
tr(“可能程序被破坏,请联系技术支持人员!”));
// return ;
}else{
qDebug()<<“outerProcess started”;
}
while(!outerProcess.waitForFinished(3000)){
// qApp->processEvents(QEventLoop::ExcludeUserInputEvents);
qApp->processEvents();
if(outerProcess.state()==QProcess::NotRunning){
qDebug()<<“Error waitForFinish of siteInfoScanner.”;
}else if(outerProcess.state()==QProcess::Starting){
qDebug()<<“the siteInfoScanner is starting”;
}else if(outerProcess.state()==QProcess::Running){
qDebug()<<“the siteInfoScanner is running”;
}
//qDebug()<<”run in waitforfinish “;
}
Categories
爪机爪机

[GAPPS][4.4.x/4.3.x] OFFICIAL 0-Day PA-GOOGLE APPS (All ROM's) [2013-12-30]

文章转载自http://forum.xda-developers.com/showthread.php?t=2397942

WHAT WE OFFER

  • We consider these apps as important as our ROM. It is sad that the ROM scene deals with so many broken/outdated or buggy packages.
  • All packages should work fine on any custom Android 4.4.x or 4.3.x ROM (Make certain to select correct version).
  • All 4.4.x GApps packages and addons are compatible with both ART and Dalvik runtimes
  • 0-day Google Apps: We update as soon as Google releases new variants
  • All apps are untouched, we do not change or modify Googles’ applications but deliver them as-is
  • Automatic Backup: It is not necessary to re-flash GApps or modules when you flash a ROM update. Most ROM’s support this function.
  • If you use Paranoid Android, your updates come as automatic OTA’s
  • We offer several variations from a full package (based on what Google ships on Nexus devices) to smaller and minimal packages.

ANDROID 4.4.x PACKAGE INFORMATION
Scroll down for Android 4.3 Package Info

GOOGLE STOCK PACKAGE
This package is recommended for most users. It includes all the Google Apps that come standard on Nexus devices.
In this package you will find the Core Base¹, Google Experience Launcher (replaces stock launcher), Google PhotoSphere Camera/Gallery², Sun Beam Live Wallpaper, and the following Play Store applications:
Chrome Browser (replaces AOSP Browser) | Cloud Print | Gmail | Google+ | Google Calendar (replaces AOSP Calendar) | Google Drive | Google Earth | Google Keep | Google Keyboard (replaces AOSP Keyboard)
Google Play Books | Google Play Games | Google Play Newsstand | Google Play Music | Google Play Movies | Google Play services | Google Text-to-Speech | Google Search
Google Wallet | Hangouts (replaces AOSP SMS App) | Maps | Quickoffice | Sound Search for Google Play | Street View on Google Maps | TalkBack | YouTube
DOWNLOAD LINKS (~275MB)
Android File Host | MediaFire | Goo.im
FULL MODULAR PACKAGE
This package is identical to the Google Stock package above except that it does NOT include the Google PhotoSphere Camera/Gallery and will not remove your stock/AOSP Keyboard, Browser, or SMS App.
If you don’t have a Nexus device and prefer to use the AOSP apps, this package would be perfect for you.
DOWNLOAD LINKS (~218MB)
Android File Host | MediaFire
MINI MODULAR PACKAGE
This package is designed for those who use limited Google apps or prefer to install apps on their own.
In this package you will find the Core Base¹, Google Experience Launcher (replaces stock launcher), and the following Play Storeapplications:
Gmail | Google+ | Google Calendar (replaces AOSP Calendar) | Google Play services | Google Search | Google Text-to-Speech |Hangouts | Maps | Street View on Google Maps | YouTube
DOWNLOAD LINKS (~120MB)
Android File Host | MediaFire | Goo.im
ADD-ON MODULES
Addon modules can be installed on top of most any GApps package, including the Mini or Full packages above.
All addon modules also include addon.d backup support, meaning their functionality will be restored after flashing a ROM update.

  • Keyboard Addon Module (~13MB)
    This addon module will install Google Keyboard along with the iWnn Emoji keyboard that comes standard on Nexus devices.
    This package does not replace the stock (AOSP) keyboard installed on your device.
  • Photosphere Camera Addon Module: (~66MB)
    This addon module will install the Photosphere Camera/Gallery on all supported Nexus devices, including the 2012 Nexus 7.
    Although the package includes the Camera/Gallery for all Nexus devices, only the specific files for your device will be installed.
  • Chrome Browser Addon Module: (~27MB)
    This addon module will install Google Chrome Browser on your device.
  • Google Bookmark Sync Addon Module: (~0.3MB)
    This addon module will install the stock/AOSP Browser Google Bookmark Sync. Since this app has been known to cause problems with ART, it is now only offered as a separate addon.
  • Google Dialer Addon Module: (~3.4MB)
    This addon module will install the Google Dialer on your phone and replace the stock/AOSP phone app.
    Install it ONLY after you have set up your device and then rebooted into Recovery. 

    NOTE: Google Dialer must NOT be flashed on a clean install or you will have FC’s.
    This addon is not without its issues and may not function 100% on all ROM’s or devices.

DOWNLOAD LINKS
Android File Host | MediaFire

Categories
木有技术

Ubuntu中的Apache设置二级域名

文章转载自:http://fengqijun.logdown.com/posts/18988-setup-subdomain-for
在之前的从wordpress搬迁到jekyll的文章中提到,搬迁最大的问题就是图片的存放和图片的连接。为此我在自己的VPS上建立了一个叫做images的二级域名来专门存放文件。

建立二级域名A记录

建立二级域名最重要的一步是在你的域名解析服务器上添加一条”*”的A记录,把*.domainname.com都mapping到你的服务器IP地址上

建立site文件

Ubuntu上的Apache设置和别的Linux有不同的地方,在/etc/apache2/sites-available目录下建一个新的site文件,建议文件名跟你的二级域名一样, 比如:images.fengqijun.me

<VirtualHost *:80>
    ServerAdmin [email protected]
    ServerName images.fengqijun.me
    DocumentRoot /path-to/blog-images/
</VirtualHost>
激活site文件

激活site文件,可以用命令

a2ensite images.fengqijun.me

成功之后,/etc/apache2/sites-enabled/目录下就会出现这个文件。如果想disable某个site,可以用

a2dissite

命令

修改hosts

在hosts中,把images.fengqijun.me mapping到 127.0.0.1
然后重启Apache,就完成了

Categories
默认分类

服务器迁移公告 – 2

blog.dayandcarrot.net的博客服务器目前已迁移至美国主机,访问速度应该与之前的香港主机相差无几
相关资源文件以及其他关联的项目正在迁移中,如有需要访问旧博客,目前可以访问www.dayandcarrot.net

Categories
生活琐碎

服务器迁移公告

因为找到了新的更自由的VPS,本人决定2个月内停用本博客现行使用的VPS服务器,数据迁移期间可能会造成短时间无法访问到博客的情况,见谅:)

Categories
爪机爪机

[固件][ODIN] Sprint L720 MK2 modem固件 {12/8/13}

本文转载自:http://forum.xda-developers.com/showthread.php?t=2338919
==================================================
Finally a way to flash modems/firmwares without needing to take the OTA!! This means no losing Root, no losing Recovery, no data wipe, just strictly updating the Firmware!!
This is FIRMWARE ONLY, not any data or system files, this will not put your device up to the latest ROM or add any features like samsung/sprint list out in their update releases. This is ONLY the firmware bits. (Modem, NON-HLOS, bootloader, sbl2, sbl3, tz, etc.)
这是固件文件,而并非任何data或系统文件,这会不会把你的设备升级至最新的ROM,这仅仅是Modem以及其他一些引导文件(不含bootloader的升级)。 (调制解调器,NANHLOS,引导程序,SBL2,SBL3,TZ等)
The firmwares are listed in the second post.
What you need需要什么:

  1. An extracted FirmwareAIO.tar.md5 from the second post下面下载连接中的Firmware文件
  2. Odin (I used 3.07, but I am pretty sure others work too)
  3. A PC… (duh)
  4. Sprint Galaxy S4
  5. A brain

Here is the procedure下面详述过程:

  1. Power OFF the phone (do not use reboot to download mode, do a full power off).手机关机(请勿直接重启至Download模式)
  2. Hold down the Volume down key and then press and hold the power Key.按下音量减+开机键,以开机至Download模式
  3. When the screen lights up, release both.屏幕亮起时,松开按键
  4. Press Volume up to Continue past the first screen, you should now be in Download Mode.按下音量加键以继续进入Download模式
  5. Plug the phone into the PC with Odin.将手机与电脑连接,打开Odin程序
  6. Fire up Odin and select the modem tar.md5 file with the PDA button.点击”PDA”按钮选择解压好的.md5后缀的文件
  7. 取消勾选”Auto Reboot”选项
  8. Click Start and Let it flash until it’s done.点击”start”开始刷写
  9. when you see PASS on Odin, unplug the phone and Hold the Power key for 10 seconds to reboot.看到PASS字样时,按住电源键10秒关机,然后重启。

MK2 Firmware – Download Link (Firmware Only – No KNOX BootLoader)
MK2 Mirror 1 – Download Link (Firmware Only – No KNOX BootLoader)
MJA Firmware – Download Link (Firmware Only – No KNOX BootLoader)
MJA Mirror 1 – Download Link (Firmware Only – No KNOX BootLoader)
Sprint MF9 Firmware – Download Link
MF9 Mirror 1 – Download Link
Sprint MDL Firmware – Download Link
MDL Mirror 1 – Download Link
Sprint MDC Firmware – Download Link
MDC Mirror 1 – Download Link

Categories
生活琐碎

西安游记 2013.冬

版权声明

转载本文章请注明来自dayandcarrot.net,任何未经许可的商业使用本人保留追责权利。

===========================================================

小小记录一下西安旅游的东西~
12月6日从上海出发,12月12日回到学校

  • 6日

主要是在车船时间,上海航空的飞机从1:55晚点到2点多,登上飞机后航空管制又延误20分钟,到的时候延误40分钟左右,然后机场大巴去的钟楼附近的宾馆耗时1hr差不多。到了钟楼附近走了将近20分钟精疲力尽终于到了宾馆,还好妹纸已经习惯了跟我出去玩老走路,感觉还挺欣慰。然后就洗洗睡了

  • 7日——大雁塔、历史博物馆、古城墙

从南到北的路线,先是打的去的大雁塔~大雁塔景区的门票是第一坑,其实外面一圈都是后面修筑的,但是也需要门票进门,学生证5折后是20元,之后进去看到大雁塔,登塔另外需要钱,折后好像是30吧~大雁塔外表大部分是保留原样的,底下一些石刻被玻璃封起来了

IMG_1472[1]

登塔其实挺好玩的说,一圈一圈转上塔顶,比起一些不能登上去的塔,还是值得的。登上塔顶往外看可以看到好远。
IMG_1478[1]
 
 
然后步行去的陕西历史博物馆。去的路上妹纸说可能人很多要排队什么,但是到的时候就发现人没那么多,门票是免费的,要刷身份证拿票,反正一两分钟搞定。进去的话,建筑物是90年代的样子,比较古老,不过里面东西确实是多!
对了,半路上买的冰峰可乐,说实话没有之前去青岛喝到的崂山可乐好喝,反正就是芬达味道嘛~
IMG_1483[1] IMG_1480[1]
 
展品没怎么拍,反正感觉琳琅满目的~
再后来坐公交(竟然是中巴车!!)去的南城门,最开心的一段时间了~从靠西侧上的城门,要买门票,反正学生价也有半价,两个人50多吧~上了城门之后发现可以租自行车,而且也有双人的自行车。貌似是定制版JAVA的车子,有点山地车的感觉,主要城墙上路坑坑洼洼不平的。
自行车80元可以骑100分钟,超时10分钟10元的样子,这个时间反正跟妹纸两个人骑了3/4圈还剩下20分钟左右,中间有休息,也是差不多时间的感觉。城墙的路坑坑洼洼的,自行车只有前叉有避震,所以就苦了屁屁了…
IMG_1495[1]
 
然后就结束了行程。晚饭忘了哪里吃的哈哈哈哈
要是南京的城墙也能骑自行车就好了,感觉维护的没有西安的城墙好。

  • 8日——兵马俑

来西安必去的地方,所以得去走走——到火车站坐大巴过去
妹纸比较细心,事先看了攻略说什么火车站有好多假的旅游巴士,然后公交坐到火车站发现真心如此——假的比真的还真!
反正正宗的旅游大巴是灰色的车子,然后车票7元。开车后收钱的人会跟你说介绍景点,其实嘛是要吆喝你去华清池什么的,她80%的时间都在介绍华清池什么的~反正咱们没有动心。。
兵马俑一共3个坑,反正坑的是售票的地方离坑远的很!门票依然学生证5折,妹纸的国际学生证在这次旅行中全程通用(除了城墙的门票),陕西人这点还是不错的。
IMG_1505[1]
 
期中1号坑最大,2号坑其次,3号坑最小。买的票是秦始皇陵和兵马俑的联票,不过据说陵墓不大好玩就没有去~坑里站着的兵马俑其实都是复原的,因为这个坑好像塌下来过,幸存的只有矮子——跪着准备射箭的俑。
IMG_1513[1]
 
总的来说还是比较值得看的,不过嘛地方略远的感觉。

  • 9日——狂爬华山

一大清早坐最早的高铁从西安北去往华山北站,华山不得不说是出刁民的地方(当然我也相信大部分人还是好人呵呵)。到站之后出了火车站就有出租车司机吆喝着说什么没有公交车去,其实边上停着的免费公交终点站就是游客中心,出租车司机反正是。。。不想说什么了。
到了游客中心,买票,然后乘免费班车去玉泉院开始徒步爬行。妹纸被我连蒙带骗爬上了山~
前面一端是坡路,没有什么景致,很枯燥的感觉。后面就是台阶了~跟妹纸分别登上了南峰,然后为了去看看长空栈道去了北峰,为了坐西峰的索道下山去了西峰,差点就登顶了,但是因为时间和体力的关系还是没上去。其实最初的计划只是北峰上去然后直接北峰索道下去的…
IMG_1551[1]
上图为——千尺幢,感慨一下这TM才是爬山嘛~
IMG_1568[1]
 
一张全景照,感觉挺漂亮
山上物价极高,因为是淡季,很多店都关门了,然后所有的都是统一价格吧,有物价部门的牌子~列举部分:
红牛=15元,茶叶蛋=3元,加热开水300ml大概3元,肉夹馍10元一个……
坑爹的是,西峰缆车下山要100一个人,然后缆车到了的话是个荒郊野岭,尼玛巴士还要40元一个,真是觉得他们为啥不一起把这钱算门票里啊…什么折扣都不打的说,西峰开车下山是个盘山公路,离城区很远,开车开了40分钟差不多!爬了6小时山身心俱疲,回程去华山北站被出租司机狠宰一把,5km的路30元呵呵呵呵….总归下次不会来这地方了吧
另外长空栈道,因为时间关系没有上去,有点感觉可惜。走一圈说是至少30分钟,所以就来不及了,唉!
到西安狂吃一顿海底捞,各种半份半份,服务还是不错的~

  • 10日-钟楼、回民街

本来计划安排去乾陵的,不过这个计划反正就是拿来改变的~
钟楼离旅店非常近,走路过去即可。钟楼是个孤岛,四周是一圈大转盘,各种车子…不过感觉这个东西能保存下来还是挺不容易的,要通过地下道走进去,依旧学生证5折…
IMG_1584[1]
 
很有幸听到了古乐器的表演,二胡、扬琴啊编钟还有磬的声音,这种声音好清澈的,感觉略喜欢。另外楼顶上可以望到南城门,感觉古时候城池好小啊!
晚上去了回民街,吃了镜糕什么的,然后嘛看到了各种吃的,人挺多的感觉,很热闹,但是总是觉得不大卫生…

  • 11日——无所事事

不多说,总觉得西安的菜不符合我的胃口。之前在老店吃的羊肉泡馍,还有11日晚上吃的Biangbiang面,感觉都不是很符合我的胃口,唯一觉得好吃一些的是肉夹馍…妹纸貌似也有差不多感觉…大概是南方人口味不和的关系吧
哦~突然记起来,爬山一定要带上手套,或者找JS买一个,2~3元一付
 

  •  =======================================================================

本次旅行总的来说还是挺开心的,主要有妹纸陪欢乐许多~哈哈

Categories
不学无术

《人机情感交互》第二章笔记

https://app.yinxiang.com/shard/s17/sh/6664be3a-1771-45c6-b346-dc8be847ea34/788022bbf47860ec99fcb41530cb77aa