Qt Components Hildon  0.20
QML components for Maemo5 with Hildon styling.
 All Classes Functions Properties Groups Pages
Public Slots | Signals | Properties | List of all members
File Class Reference

Provides an interface for reading from and writing to files. More...

Public Slots

void close ()
 Closes the file.
bool open (int mode)
 Opens the file using mode.
string read (int maxSize)
 Reads maxSize bytes from the file and returns the data.
string readAll ()
 Reads all bytes from the file and returns the data.
string readLine (int maxSize=0)
 Reads maxSize bytes from the current line of the file and returns the data.
bool remove ()
 Removes the file from the file system.
bool rename (string newName)
 Renames the file to newName.
int write (string byteArray)
 Writes byteArray to the file and returns the number of bytes written.

Signals

void error ()
 Emitted when an error occurs.

Properties

string errorString
 A description of the last error that occurred.
bool exists
 Whether the file specified by fileName exists.
string fileName
 The file name.
bool isOpen
 Whether the file is open.
enumeration openMode
 The mode used to open the file.
flags permissions
 The complete OR-ed together combination of File.Permission for the file.
int pos
 The current position in bytes.
int size
 The size of the file in bytes.

Detailed Description

Provides an interface for reading from and writing to files.

File provides a subset of the C++ QFile API.

import QtQuick 1.0
import org.hildon.components 1.0
import org.hildon.utils 1.0
Window {
id: window
title: qsTr("File Example")
visible: true
Column {
id: column
anchors {
left: parent.left
right: parent.right
top: parent.top
}
width: parent.width
text: qsTr("File name")
}
id: fileNameField
width: parent.width
}
Button {
id: button
width: parent.width
text: qsTr("Read file")
onClicked: edit.text = file.readAll()
}
width: parent.width
text: qsTr("Result")
}
id: edit
width: parent.width
readOnly: true
}
}
File {
id: file
fileName: fileNameField.text
onError: console.log(errorString)
}
}
See Also
Directory
Examples:
file.qml.

Member Function Documentation

void File::close ( )
slot

Closes the file.

See Also
isOpen, openMode, open()
File::error ( )
signal

Emitted when an error occurs.

See Also
errorString
bool File::open ( int  mode)
slot

Opens the file using mode.

See Also
isOpen, openMode
string File::read ( int  maxSize)
slot

Reads maxSize bytes from the file and returns the data.

See Also
readAll(), readLine()
string File::readAll ( )
slot

Reads all bytes from the file and returns the data.

See Also
read(), readLine()
string File::readLine ( int  maxSize = 0)
slot

Reads maxSize bytes from the current line of the file and returns the data.

See Also
read(), readAll()
bool File::remove ( )
slot

Removes the file from the file system.

Returns true if successful.

bool File::rename ( string  newName)
slot

Renames the file to newName.

Returns true if successful.

See Also
fileName

Property Documentation

bool File::isOpen
read

Whether the file is open.

The default value is false.

See Also
close(), open()
enumeration File::openMode
read

The mode used to open the file.

Possible values are:

Name Description
File.NotOpen The file is not open (default).
File.ReadOnly The file is open for reading.
File.WriteOnly The file is open for writing
File.ReadWrite The file is open for reading and writing.
File.Append The file is opened in append mode, so that all data is written to the end of the file.
File.Truncate If possible, the file is truncated before it is opened.
File.Text The end-of-line terminators are translated to '\n'.
File.Unbuffered Any buffer is bypassed.
See Also
isOpen, open()
flags File::permissions
readwrite

The complete OR-ed together combination of File.Permission for the file.

Possible values are:

Name Description
File.ReadOwner The file is readable by the owner of the file.
File.WriteOwner The file is writable by the owner of the file.
File.ExeOwner The file is executable by the owner of the file.
File.ReadUser The file is readable by the user.
File.WriteUser The file is writable by the user.
File.ExeUser The file is executable by the user.
File.ReadGroup The file is readable by the group.
File.WriteGroup The file is writable by the group.
File.ExeGroup The file is executable by the group.
File.ReadOther The file is readable by anyone.
File.WriteOther The file is writable by anyone.
File.ExeOther The file is executable by anyone.