开发者

Browse folders and add their files to a list with qt

Hello Great community of SO!

I have created a GUI application with qt and I added a QTreeWidget and a 2 buttons (add and delete) in my main window.

Is it possible to find examples of code in order to learn how to add and delete files to this QTreeWidget ?


For directory browsing try QDir. To create and remove files use QFile. Quite a lot of examples and tutorials can be found here Qt documentation. Just select your release.


Did you look at the demos that come bundled with Qt itself? I can tell you of two examples:

  1. In QtAssistant, go to Qt Reference Documentation->Overviews->View Classes and you have your example.

  2. More elaborate: In QtAssistant, go to: Qt Reference Documentation->Tutorials and Examples: Under XQuery,XPath you have File System Example.

Adding file can be as simple as opening a new file (taking the filename from user) and closing it (I don't know what exactly you want here - some equivalent of "touch" command?).

For deleting, you can call: bool QDir::remove ( const QString & fileName )

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜