Problem on SIGNALS and SLOTS
-
I designed a GUI to upload and download files from my FTP server
when i click on upload button, uploads my file on the server successfully.
in order to see upload progress added a progress bar to the GUI.
I know that when uploading and downloading dataTransferProgress() signal is emited.
I tried to connect this signal to my progress bar:connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), this ,SLOT(ui->progressBar_Upload));
I receive no error but it doesnt work!
-
@rezaMSLM said in Problem on SIGNALS and SLOTS:
connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), this ,SLOT(ui->progressBar_Upload));
there's defenitly an error, but the old Signal/Slot syntax does not show it during compile time.
try the following:
connect(ftp, QFTP::dataTransferProgress, ui->progressBar_Upload ,[=](qint64 current, qint64 max){ ui->progressBar_Upload->setValue(current); ui->progressBar_Upload->setMaximum(max); });
this should work.
If you're bound to qt4 or something, you'll need a slot in your Class(Mainwindow?)connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), this ,SLOT(newProgressValues(qint64, qint64)); void Mainwindow::newProgressValues(qint64 current, qint64 max){ ui->progressBar_Upload->setValue(current); ui->progressBar_Upload->setMaximum(max); }
-
- check if connection worked (
connect()
returns a bool) - use new connection syntax - it will give you compilation errors when something is wrong in connection statement
- you are not specifying any actual slot in your SLOT() macro call, so I'm 99% sure it fails there. You should rather do it like:
connect(ftp, SIGNAL(dataTransferProgress(qint64, qint64)), ui->progressBar_Upload ,SLOT(nameOfYourSlot(qint64, qint64)));
- check if connection worked (
-
Oh, what timing :)
-
Haha, nice :-)
-
@J.Hilk said in Problem on SIGNALS and SLOTS:
@sierdzio for the "easy questions" people tend to answer within the same minute. I had it once, where 5 people answred within 1 minute x)
I'm starting to think we should have Sticky threads for those... :P
-
when using QFtp::put() command I want to be noticed whether the command successfully finished or not; so I want to use "void QFtp::commandFinished ( int id, bool error )" SIGNAL.
from Qt help:
"This signal is emitted when processing the command identified by id has finished"
now my question is that what is QFtp::put() command id?
in other words:
when commandfinished() signal is emitted how I understand which command is finished? -
@rezaMSLM said in Problem on SIGNALS and SLOTS:
now my question is that what is QFtp::put() command id?
Please read the documentation: http://doc.qt.io/archives/qt-4.8/qftp.html#put-2
The id is what QFtp::put() returns...