Sınıfımdan finished()
sinyali göndermeye çalıştım. Ama sinyali yuvama bağladığımda, hiçbir şey yapmadı.Yayılan Sinyal Algılanmadı
Sınıfımın adı blend_install
, ben blendinstaller
olarak bildirdim ve bunu QEventLoop'a bağlamaya çalıştım.
....
QEventLoop ac;
connect(&blendinstaller, SIGNAL(finished()), &ac, SLOT(quit()));
blendinstaller.show_progress();
blendinstaller.download(); // this will execute everything and in the end emit finished()
ac.exec();
....
download()
fonksiyonu:
current_prog = BLEND_INSTALL_NONE;
emit progress_changed(current_prog);
manager = new QNetworkAccessManager;
file_handler = new QFile(downloadTo);
file_handler->open(QFile::WriteOnly);
.... handle error .... // each of this (error handling) will emit finished() signal and return;
.... // each of this will represent the process of reporting event changes (for logging), emit a SIGNAL()
QNetworkRequest request;
request.setUrl(QUrl(downloadFrom));
reply = manager->get(request);
event = new QEventLoop;
connect(reply,SIGNAL(finished()),event,SLOT(quit()));
connect(reply,SIGNAL(error(QNetworkReply::NetworkError)),this,SLOT(downloadError(QNetworkReply::NetworkError)));
connect(reply,SIGNAL(downloadProgress(qint64,qint64)),this,SLOT(downloadProgressL(qint64,qint64)));
event->exec();
.... handle error ....
.... write reply.readAll() to file ....
....
// these are instruction for a custom QProcess instance
proc.setProgram(extractWith);
proc.setArguments(ar);
proc.setWorkingDirectory(downloadIn);
event = new QEventLoop;
connect(&proc,SIGNAL(finished(int)),event,SLOT(quit()));
connect(&proc,SIGNAL(error(QProcess::ProcessError)),this,SLOT(extractError(QProcess::ProcessError)));
connect(&proc,SIGNAL(finished(int,QProcess::ExitStatus)),this,SLOT(extractFinished(int,QProcess::ExitStatus)));
proc.start();
proc.open_console();
event->exec();
.... handle error ....
....
.... attempt to find output of QProcess (extract an archive) ....
.... handle error, output of QProcess not found ....
....
emit installed(installOn);
emit finished(); // the SIGNAL I want to get.
qDebug("It's finished installing!");
Yani, TL; DR taşıma hataların her işlevinden dönmek değil, aynı zamanda finished()
yayarlar ve fonksiyon sonunda (hiçbir hata yoktur varsayarak olacak) finished()
yayar.
Döngüden çıkmaz.
Herhangi bir fikrin var mı?
Bu ince görünüyor:
İşte Güncelleme 2. elbette mükemmel değil, küçük bir örnek vardır. İndirme() 'uygulamanızı yayınlayabilir misiniz? Sadece 'download()' yönteminin 'bitmiş()' sinyalin çok erken yayıldığını hayal edebiliyorum. Daha iyi dedi ki: Bu hiç denilmemelidir. Genellikle bir tür özel yuva 'onDownloadComplete()' bitmiş() 'sinyalini yayar. – mfreiholz
@mfreiholz Bunu yükledim ve önerinizi deneyeceğim ... –
Her zaman "Yüklemeyi bitirmiş!" mesaj, ama hala bitmiş() 'sinyalini yaymaz. –