QAbstractFileEngineHandler Class ReferenceThe QAbstractFileEngineHandler class provides a way to register custom file engines with your application. More... #include <QAbstractFileEngineHandler> Note: All functions in this class are reentrant. This class was introduced in Qt 4.1. Public Functions
Detailed DescriptionThe QAbstractFileEngineHandler class provides a way to register custom file engines with your application. QAbstractFileEngineHandler is a factory for creating QAbstractFileEngine objects (file engines), which are used internally by QFile, QFileInfo, and QDir when working with files and directories. When you open a file, Qt chooses a suitable file engine by passing the file name from QFile or QDir through an internal list of registered file engine handlers. The first handler to recognize the file name is used to create the engine. Qt provides internal file engines for working with regular files and resources, but you can also register your own QAbstractFileEngine subclasses. To install an application-specific file engine, you subclass QAbstractFileEngineHandler and reimplement create(). When you instantiate the handler (e.g. by creating an instance on the stack or on the heap), it will automatically register with Qt. (The latest registered handler takes precedence over existing handlers.) For example: class ZipEngineHandler : public QAbstractFileEngineHandler { public: QAbstractFileEngine *create(const QString &fileName) const; }; QAbstractFileEngine *ZipEngineHandler::create(const QString &fileName) const { // ZipEngineHandler returns a ZipEngine for all .zip files return fileName.toLower().endsWith(".zip") ? new ZipEngine(fileName) : 0; } int main(int argc, char **argv) { QApplication app(argc, argv); ZipEngineHandler engine; MainWindow window; window.show(); return app.exec(); } When the handler is destroyed, it is automatically removed from Qt. The most common approach to registering a handler is to create an instance as part of the start-up phase of your application. It is also possible to limit the scope of the file engine handler to a particular area of interest (e.g. a special file dialog that needs a custom file engine). By creating the handler inside a local scope, you can precisely control the area in which your engine will be applied without disturbing file operations in other parts of your application. See also QAbstractFileEngine and QAbstractFileEngine::create(). Member Function Documentation
|
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.8 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com