• 9495阅读
  • 8回复

[提问]QT 读写xml怎么加锁 [复制链接]

上一主题 下一主题
离线ktang1220
 

只看楼主 倒序阅读 楼主  发表于: 2012-06-15
我需要利用多线程编程,但是每个线程可能对同一个xml文件进行操作,请问如何实现线程之间的读写互斥问题
windows下面有没有文件的读写加锁的操作呢?
在线XChinux

只看该作者 1楼 发表于: 2012-06-16
Qt中有QThread, QMutex等这些类的.
二笔 openSUSE Vim N9 BB10 XChinux@163.com 网易博客 腾讯微博
承接C++/Qt、Qt UI界面、PHP及预算报销系统开发业务
离线ppdayz

只看该作者 2楼 发表于: 2012-06-16
回 楼主(ktang1220) 的帖子


The Solutions - available at <A href="http://qt.gitorious.org/qt-solutions" target=_blank jQuery1339808835734="2" offSite?>http://qt.gitorious.org/qt-solutions

  • Qt/MFC Migration Framework
    The Qt/MFC Migration Framework tool assists in the migration of existing Win32 or MFC applications to the Qt framework.
  • Property Browser
    A property browser framework enabling the user to edit a set of properties.
  • Browser Plugin  
    The QtBrowserPlugin solution is useful for implementing plugins within a web browser.
  • JPEG 2000 Image Format  
    The JPEG 2000 Image Format provides a QImageIOHandler plugin for reading and writing JPEG 2000 files.
  • Locked File  
    The QtLockedFile class extends QFile with advisory locking functions.
  • QtScript Classic  
    This component provides the original (pre-Qt 4.6) implementation of the QtScript module.
  • Service
    The QtService component is useful for developing Windows services and Unix daemons.
  • Single Application  
    The QtSingleApplication component provides support for applications that can be only started once per user.
  • SOAP
    The Qt SOAP project provides basic web service support with version 1.1 of the SOAP protocol.
离线uidab

只看该作者 3楼 发表于: 2012-06-16
回 2楼(ppdayz) 的帖子
这个东西不错哦!
有时候为了工作直接获得答案,而我却失去了思考的乐趣!


飘啊飘,何时能安居!
离线ktang1220

只看该作者 4楼 发表于: 2012-06-17
回 1楼(XChinux) 的帖子
那个是线程锁定变量的用法吧?这个是想读写xml文件用的,想用那种文件锁!
而且是很多不同的文件。
离线ktang1220

只看该作者 5楼 发表于: 2012-06-17
回 2楼(ppdayz) 的帖子
QtLockedFile俺回去查查这个类哈
离线ktang1220

只看该作者 6楼 发表于: 2012-06-17
回 2楼(ppdayz) 的帖子
2楼,为啥子俺没找到这个类?是商业版里才有吗?
离线ppdayz

只看该作者 7楼 发表于: 2012-06-17
回 6楼(ktang1220) 的帖子
看标题~~
本来只是为商业版写的,后来统一了,现在无论什么授权源码都是一样的
只不过对应的权利个义务不一样的
标题上有下载的地址
你可以编译成库来用,也可以直接加载源码
离线ninsun

只看该作者 8楼 发表于: 2012-06-17
文件锁这种玩意,完全可以自己实现嘛..
参照linux系统,打开文件的时候创建一个xxxx.lock空文件, 如果这个文件已经存在了,则打开失败
关闭文件的时候吧自己创建的xxxx.lock文件在给删掉就行了....
快速回复
限100 字节
 
上一个 下一个