LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   QFile and QProgressBar. (https://www.linuxquestions.org/questions/programming-9/qfile-and-qprogressbar-690102/)

elprawn 12-12-2008 09:37 AM

QFile and QProgressBar.
 
Okay, so I realise that I can't capture the bytesWritten() signal in order to show the file copy progress of the QFile.copy() function on a QProgressBar, but it's my understanding that this can be done using the QIODevice class, be it somewhat more complicated.

How might one go about achieving this in C++?

Thank you for you help.

ErV 12-12-2008 09:45 AM

Quote:

Originally Posted by elprawn (Post 3373094)
Okay, so I realise that I can't capture the bytesWritten() signal in order to show the file copy progress of the QFile.copy()

Why? o_O
Besides, what Qt version?
In Qt 4 - derive your own class from QProgressBar that has slot that accepts quint64. Or make temporary slot somewhere that can be linked to QFile's signal and will emit another signal for QProgressBar.

elprawn 12-12-2008 09:56 AM

Qt 4.

Quote:

Originally Posted by Online Documentation
Unlike other QIODevice implementations, such as QTcpSocket, QFile does not emit the aboutToClose(), bytesWritten(), or readyRead() signals. This implementation detail means that QFile is not suitable for reading and writing certain types of files, such as device files on Unix platforms.

And I should probably say at this stage I don't have much experience in programming in C++ but I understand in principle what you're saying about deriving a class that will allow me to access the signal.

Thanks once again.

ErV 12-12-2008 11:11 AM

Quote:

Originally Posted by elprawn (Post 3373115)
Qt 4.



And I should probably say at this stage I don't have much experience in programming in C++ but I understand in principle what you're saying about deriving a class that will allow me to access the signal.

Thanks once again.

Well, I thought it was emitting signal.

If it isn't emitting signal, then you can create your own copy routine (or class or whatever), that will emit required signal. You might even try to make your own QFile derivative that supports those signals, but that might be too difficult. If I were you I'd write class (based on Q_OBJECT, of course) for copying files, and made it emit signals you need.


All times are GMT -5. The time now is 11:59 AM.