Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Application Development with Qt Creator - Second Edition
  • Toc
  • feedback
Application Development with Qt Creator - Second Edition

Application Development with Qt Creator - Second Edition

4 (25)
close
Application Development with Qt Creator - Second Edition

Application Development with Qt Creator - Second Edition

4 (25)

Overview of this book

This book is great for developers who are new to Qt and Qt Creator and who are interested in harnessing the power of Qt for cross-platform development. If you have basic experience programming in C++, you have what it takes to create engaging cross-platform applications using Qt and Qt Creator!
Table of Contents (15 chapters)
close
14
Index

Accessing files using Qt

Files are a specialization of a generalized notion—that of a byte stream that resides somewhere else. Qt encapsulates the more generalized notion of byte streams in its QIODevice class, which is the parent class for QFile as well as network I/O classes such as QTcpSocket. We don't directly create a QIODevice instance, of course, but instead create a subclass such as QFile and then work with the QFile instance directly to read from and write to the file.

Tip

Files and network access usually take time, and thus, your applications shouldn't work with them on the main thread. Consider creating a subclass of QThread to perform I/O operations such as reading from files or accessing the network.

To begin working with a file, we first must open it using the open method. The open method takes a single argument, the manner in which the file should be opened, a bitwise combination of the following:

  • QIODevice::ReadOnly: This is used for read-only access
  • QIODevice...
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete