Sponsored Content
Top Forums Programming Proximity-card reader: no data when app window out of focus Post 302344999 by Dp0H on Tuesday 18th of August 2009 07:39:51 AM
Old 08-18-2009
With the following modification my windowing code gets all the counted signals:
Code:
bool MarinReader::read_port(QFile* file)
{
	static int i = 0;
	emit Message("debug message #" + QString::number(i++));
	char first_char = '\0';
	file->getChar(&first_char);
	if (first_char == ':')
	{
		QByteArray bres = file->readAll();
		QString s(bres);
		s.resize(10);
		emit CardProcessed(s);
	}
	tcflush(file->handle(), TCIOFLUSH);
	return true;
}

Signals CardProcessed and Message are identical, and the destination slots are in the same thread of main window (I can process these signals with the same slot).
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

MSR magnetic stripe card reader

Hi all I am working on MSR110 ...Can anyone plz tell me how to use the configuration commands with magnetic reader???. Please help me out as i have to develop API in C on linux platform.MSR110 is not responding to the configuration commands. Please help... Regards Mahima (0 Replies)
Discussion started by: mahima_er
0 Replies

2. Programming

Hiding app window

I am facing a problem while creating/executing a process in C. I am using old fork/exec mechanism. The problem is: I want to hide the console window of the app i am instantiating. Remember i am instantiating a console application from a GUI application. Is this possible? How? Comments are... (1 Reply)
Discussion started by: amessbee
1 Replies

3. Solaris

Secure Card Reader

I see on some of the recent Sun workstations that there is a secure card reader installed. I have a Sunblade 100 and 150 and would like to know, how do you access this device or turn it on to use it? Thanks, (2 Replies)
Discussion started by: stocksj
2 Replies

4. Shell Programming and Scripting

Bash: Exiting while true loop when terminal is not the focus window

I am running an Ubuntu Gutsy laptop with Advanced Compiz fusion options enabled. I am using xdotool to simulate keyboard input in order to rotate through multiple desktops. I am looking for a way to kill a while true loop when the Enter key (or Control+C if it is easier) is pushed when the... (2 Replies)
Discussion started by: acclaypool
2 Replies

5. Programming

Multithread app - Read-Only Data

Hello, I'm coding an application using pthreads.At some point the threads will read some read-only variables.Is it safe NOT to use mutexes, in order to make the program lighter since mutex operations are resource-demanding... Thanks (1 Reply)
Discussion started by: jonas.gabriel
1 Replies

6. UNIX for Dummies Questions & Answers

grab the data from the unix window

Hi, How could i grab a set of data (eg:file execution start & stop time stamp f) from unix? (1 Reply)
Discussion started by: siriv
1 Replies

7. What is on Your Mind?

CNET News Reader App for the Forums

We are thinking of building a CNET style reader app for reading threads in the forums. One developer suggested we look at a CNN vBulletin app, which I am not familiar with (he said he will post the link tomorrow, Monday). Anyway, I asked the (potential) developer for this app to work with us in... (1 Reply)
Discussion started by: Neo
1 Replies

8. Programming

Building app. to send data to website

Hi. I plan to build an application which takes text data from a user. It then sends this to a website, login required. The business case being this site contains many text fields, mostly redundant to user. My application would only prompt user for necessary text. What language, methods... (4 Replies)
Discussion started by: cic
4 Replies

9. UNIX for Dummies Questions & Answers

How to regain the focus back to the launch window?

Consider this code snippet below:- char=`which afplay` if then xterm -e 'while true; do clear; echo "Press Ctrl-C to Quit..."; afplay /tmp/pulse.wav; done' & > /dev/null 2>&1 fi This launches a second terminal window that generates a specific waveform for the next calibration of... (4 Replies)
Discussion started by: wisecracker
4 Replies
QFile(3qt)																QFile(3qt)

NAME
QFile - I/O device that operates on files SYNOPSIS
Almost all the functions in this class are reentrant when Qt is built with thread support. The exceptions are setEncodingFunction() and setDecodingFunction().</p> #include <qfile.h> Inherits QIODevice. Public Members QFile () QFile ( const QString & name ) ~QFile () QString name () const void setName ( const QString & name ) typedef QCString (* EncoderFn ) ( const QString & fileName ) typedef QString (* DecoderFn ) ( const QCString & localfileName ) bool exists () const bool remove () virtual bool open ( int m ) bool open ( int m, FILE * f ) bool open ( int m, int f ) virtual void close () virtual void flush () virtual Offset size () const virtual bool atEnd () const virtual Q_LONG readLine ( char * p, Q_ULONG maxlen ) Q_LONG readLine ( QString & s, Q_ULONG maxlen ) virtual int getch () virtual int putch ( int ch ) virtual int ungetch ( int ch ) int handle () const Static Public Members QCString encodeName ( const QString & fileName ) QString decodeName ( const QCString & localFileName ) void setEncodingFunction ( EncoderFn f ) void setDecodingFunction ( DecoderFn f ) bool exists ( const QString & fileName ) bool remove ( const QString & fileName ) Important Inherited Members virtual QByteArray readAll () DESCRIPTION
The QFile class is an I/O device that operates on files. QFile is an I/O device for reading and writing binary and text files. A QFile may be used by itself or more conveniently with a QDataStream or QTextStream. The file name is usually passed in the constructor but can be changed with setName(). You can check for a file's existence with exists() and remove a file with remove(). The file is opened with open(), closed with close() and flushed with flush(). Data is usually read and written using QDataStream or QTextStream, but you can read with readBlock() and readLine() and write with writeBlock(). QFile also supports getch(), ungetch() and putch(). The size of the file is returned by size(). You can get the current file position or move to a new file position using the at() functions. If you've reached the end of the file, atEnd() returns TRUE. The file handle is returned by handle(). Here is a code fragment that uses QTextStream to read a text file line by line. It prints each line with a line number. QStringList lines; QFile file( "file.txt" ); if ( file.open( IO_ReadOnly ) ) { QTextStream stream( &file ); QString line; int i = 1; while ( !stream.eof() ) { line = stream.readLine(); // line of text excluding ' ' printf( "%3d: %s ", i++, line.latin1() ); lines += line; } file.close(); } Writing text is just as easy. The following example shows how to write the data we read into the string list from the previous example: QFile file( "file.txt" ); if ( file.open( IO_WriteOnly ) ) { QTextStream stream( &file ); for ( QStringList::Iterator it = lines.begin(); it != lines.end(); ++it ) stream << *it << " "; file.close(); } The QFileInfo class holds detailed information about a file, such as access permissions, file dates and file types. The QDir class manages directories and lists of file names. Qt uses Unicode file names. If you want to do your own I/O on Unix systems you may want to use encodeName() (and decodeName()) to convert the file name into the local encoding. See also QDataStream, QTextStream, and Input/Output and Networking. Member Type Documentation QFile::DecoderFn This is used by QFile::setDecodingFunction(). QFile::EncoderFn This is used by QFile::setEncodingFunction(). MEMBER FUNCTION DOCUMENTATION
QFile::QFile () Constructs a QFile with no name. QFile::QFile ( const QString & name ) Constructs a QFile with a file name name. See also setName(). QFile::~QFile () Destroys a QFile. Calls close(). bool QFile::atEnd () const [virtual] Returns TRUE if the end of file has been reached; otherwise returns FALSE. See also size(). Reimplemented from QIODevice. void QFile::close () [virtual] Closes an open file. The file is not closed if it was opened with an existing file handle. If the existing file handle is a FILE*, the file is flushed. If the existing file handle is an int file descriptor, nothing is done to the file. Some "write-behind" filesystems may report an unspecified error on closing the file. These errors only indicate that something may have gone wrong since the previous open(). In such a case status() reports IO_UnspecifiedError after close(), otherwise IO_Ok. See also open() and flush(). Examples: Reimplemented from QIODevice. QString QFile::decodeName ( const QCString & localFileName ) [static] This does the reverse of QFile::encodeName() using localFileName. See also setDecodingFunction(). QCString QFile::encodeName ( const QString & fileName ) [static] When you use QFile, QFileInfo, and QDir to access the file system with Qt, you can use Unicode file names. On Unix, these file names are converted to an 8-bit encoding. If you want to do your own file I/O on Unix, you should convert the file name using this function. On Windows NT/2000, Unicode file names are supported directly in the file system and this function should be avoided. On Windows 95, non- Latin1 locales are not supported. By default, this function converts fileName to the local 8-bit encoding determined by the user's locale. This is sufficient for file names that the user chooses. File names hard-coded into the application should only use 7-bit ASCII filename characters. The conversion scheme can be changed using setEncodingFunction(). This might be useful if you wish to give the user an option to store file names in UTF-8, etc., but be aware that such file names would probably then be unrecognizable when seen by other programs. See also decodeName(). bool QFile::exists ( const QString & fileName ) [static] Returns TRUE if the file given by fileName exists; otherwise returns FALSE. Examples: bool QFile::exists () const This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Returns TRUE if this file exists; otherwise returns FALSE. See also name(). void QFile::flush () [virtual] Flushes the file buffer to the disk. close() also flushes the file buffer. Reimplemented from QIODevice. int QFile::getch () [virtual] Reads a single byte/character from the file. Returns the byte/character read, or -1 if the end of the file has been reached. See also putch() and ungetch(). Reimplemented from QIODevice. int QFile::handle () const Returns the file handle of the file. This is a small positive integer, suitable for use with C library functions such as fdopen() and fcntl(), as well as with QSocketNotifier. If the file is not open or there is an error, handle() returns -1. See also QSocketNotifier. QString QFile::name () const Returns the name set by setName(). See also setName() and QFileInfo::fileName(). bool QFile::open ( int m ) [virtual] Opens the file specified by the file name currently set, using the mode m. Returns TRUE if successful, otherwise FALSE. The mode parameter m must be a combination of the following flags: <center>.nf </center> The raw access mode is best when I/O is block-operated using a 4KB block size or greater. Buffered access works better when reading small portions of data at a time. Warning: When working with buffered files, data may not be written to the file at once. Call flush() to make sure that the data is really written. Warning: If you have a buffered file opened for both reading and writing you must not perform an input operation immediately after an output operation or vice versa. You should always call flush() or a file positioning operation, e.g. at(), between input and output operations, otherwise the buffer may contain garbage. If the file does not exist and IO_WriteOnly or IO_ReadWrite is specified, it is created. Example: QFile f1( "/tmp/data.bin" ); f1.open( IO_Raw | IO_ReadWrite ); QFile f2( "readme.txt" ); f2.open( IO_ReadOnly | IO_Translate ); QFile f3( "audit.log" ); f3.open( IO_WriteOnly | IO_Append ); See also name(), close(), isOpen(), and flush(). Examples: Reimplemented from QIODevice. bool QFile::open ( int m, FILE * f ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Opens a file in the mode m using an existing file handle f. Returns TRUE if successful, otherwise FALSE. Example: #include <stdio.h> void printError( const char* msg ) { QFile f; f.open( IO_WriteOnly, stderr ); f.writeBlock( msg, qstrlen(msg) ); // write to stderr f.close(); } When a QFile is opened using this function, close() does not actually close the file, only flushes it. Warning: If f is stdin, stdout, stderr, you may not be able to seek. See QIODevice::isSequentialAccess() for more information. See also close(). bool QFile::open ( int m, int f ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Opens a file in the mode m using an existing file descriptor f. Returns TRUE if successful, otherwise FALSE. When a QFile is opened using this function, close() does not actually close the file. The QFile that is opened using this function, is automatically set to be in raw mode; this means that the file input/output functions are slow. If you run into performance issues, you should try to use one of the other open functions. Warning: If f is one of 0 (stdin), 1 (stdout) or 2 (stderr), you may not be able to seek. size() is set to INT_MAX (in limits.h). See also close(). int QFile::putch ( int ch ) [virtual] Writes the character ch to the file. Returns ch, or -1 if some error occurred. See also getch() and ungetch(). Reimplemented from QIODevice. QByteArray QIODevice::readAll () [virtual] This convenience function returns all of the remaining data in the device. Q_LONG QFile::readLine ( char * p, Q_ULONG maxlen ) [virtual] Reads a line of text. Reads bytes from the file into the char* p, until end-of-line or maxlen bytes have been read, whichever occurs first. Returns the number of bytes read, or -1 if there was an error. Any terminating newline is not stripped. This function is only efficient for buffered files. Avoid readLine() for files that have been opened with the IO_Raw flag. See also readBlock() and QTextStream::readLine(). Reimplemented from QIODevice. Q_LONG QFile::readLine ( QString & s, Q_ULONG maxlen ) This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Reads a line of text. Reads bytes from the file into string s, until end-of-line or maxlen bytes have been read, whichever occurs first. Returns the number of bytes read, or -1 if there was an error, e.g. end of file. Any terminating newline is not stripped. This function is only efficient for buffered files. Avoid using readLine() for files that have been opened with the IO_Raw flag. Note that the string is read as plain Latin1 bytes, not Unicode. See also readBlock() and QTextStream::readLine(). bool QFile::remove () Removes the file specified by the file name currently set. Returns TRUE if successful; otherwise returns FALSE. The file is closed before it is removed. bool QFile::remove ( const QString & fileName ) [static] This is an overloaded member function, provided for convenience. It behaves essentially like the above function. Removes the file fileName. Returns TRUE if successful, otherwise FALSE. void QFile::setDecodingFunction ( DecoderFn f ) [static] Warning: This function is not reentrant.</p> Sets the function for decoding 8-bit file names to f. The default uses the locale-specific 8-bit encoding. See also encodeName() and decodeName(). void QFile::setEncodingFunction ( EncoderFn f ) [static] Warning: This function is not reentrant.</p> Sets the function for encoding Unicode file names to f. The default encodes in the locale-specific 8-bit encoding. See also encodeName(). void QFile::setName ( const QString & name ) Sets the name of the file to name. The name can have no path, a relative path or an absolute absolute path. Do not call this function if the file has already been opened. If the file name has no path or a relative path, the path used will be whatever the application's current directory path is at the time of the open() call. Example: QFile file; QDir::setCurrent( "/tmp" ); file.setName( "readme.txt" ); QDir::setCurrent( "/home" ); file.open( IO_ReadOnly ); // opens "/home/readme.txt" under Unix Note that the directory separator "/" works for all operating systems supported by Qt. See also name(), QFileInfo, and QDir. Offset QFile::size () const [virtual] Returns the file size. See also at(). Example: table/statistics/statistics.cpp. Reimplemented from QIODevice. int QFile::ungetch ( int ch ) [virtual] Puts the character ch back into the file and decrements the index if it is not zero. This function is normally called to "undo" a getch() operation. Returns ch, or -1 if an error occurred. See also getch() and putch(). Reimplemented from QIODevice. SEE ALSO
http://doc.trolltech.com/qfile.html http://www.trolltech.com/faq/tech.html COPYRIGHT
Copyright 1992-2001 Trolltech AS, http://www.trolltech.com. See the license file included in the distribution for a complete license statement. AUTHOR
Generated automatically from the source code. BUGS
If you find a bug in Qt, please report it as described in http://doc.trolltech.com/bughowto.html. Good bug reports help us to help you. Thank you. The definitive Qt documentation is provided in HTML format; it is located at $QTDIR/doc/html and can be read using Qt Assistant or with a web browser. This man page is provided as a convenience for those users who prefer man pages, although this format is not officially supported by Trolltech. If you find errors in this manual page, please report them to qt-bugs@trolltech.com. Please include the name of the manual page (qfile.3qt) and the Qt version (3.1.1). Trolltech AS 9 December 2002 QFile(3qt)
All times are GMT -4. The time now is 05:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy