qeventloop

Getting Pixmap is a null pixmap on calling a function 500 times

≡放荡痞女 提交于 2020-01-06 19:31:43
问题 I am showing a image in qt label. Below is my code: void MyClass::onPushButtonClicked(QString myurl) { this->setCursor(Qt::WaitCursor); ui.qtImageLabel->clear(); qDebug()<<QTime::currentTime()<<"MyClass: onPushButtonClicked"; QNetworkAccessManager *qnam_push_button_clicked_show_image; QNetworkReply *reply; QNetworkRequest request; request.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); QUrl url(myurl); request.setUrl(url); qnam_push_button_clicked_show

Getting Pixmap is a null pixmap on calling a function 500 times

泪湿孤枕 提交于 2020-01-06 19:31:04
问题 I am showing a image in qt label. Below is my code: void MyClass::onPushButtonClicked(QString myurl) { this->setCursor(Qt::WaitCursor); ui.qtImageLabel->clear(); qDebug()<<QTime::currentTime()<<"MyClass: onPushButtonClicked"; QNetworkAccessManager *qnam_push_button_clicked_show_image; QNetworkReply *reply; QNetworkRequest request; request.setHeader( QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded" ); QUrl url(myurl); request.setUrl(url); qnam_push_button_clicked_show

QEventLoop proper usage

倖福魔咒の 提交于 2020-01-01 09:12:42
问题 I have doubts how should I use QEventLoop . I have 2 pieces of code, both of them work for me (get web resource downloaded). First one: QNetworkAccessManager *manager = new QNetworkAccessManager( this ); QNetworkRequest request; request.setUrl(QUrl(url)); request.setRawHeader("User-Agent", "Mozilla Firefox"); connect(manager, SIGNAL(finished(QNetworkReply*)),this,SLOT(replyFinished(QNetworkReply*))); manager->get( request ) ; QEventLoop loop; connect(manager, SIGNAL(finished(QNetworkReply*)),

Unable to click on QRadioButton after linking it with QtCore.QEventLoop()

夙愿已清 提交于 2019-12-13 22:14:56
问题 Few days back i had situation where i had to check/uncheck QRadioButton in for loop. Here is the link Waiting in for loop until QRadioButton get checked everytime? After implementing QEventLoop on this, it worked fine until today. Now i have seen my QRadioButton(pass) button allow me to click on it but not the second QRadioButton(fail). Fail QRadioButton neither gets hang nor disable but its just i am not able to click on it. My QEventLoop code is : #QLoopEvent self.loop = QtCore.QEventLoop()

Does calling QDialog::exec in a slot block the main event loop?

无人久伴 提交于 2019-12-09 12:57:57
问题 My Qt application's main window is a normal QMainWindow subclass. In that window I have a few buttons; each has its clicked signal connected its own slot, and each slot creates a different QDialog like so: void onButtonA_clicked() { MyADialog* dialog = new MyADialog(this); dialog->exec(); delete dialog; } I've been reading this article: https://wiki.qt.io/Threads_Events_QObjects#Events_and_the_event_loop and the author says you should never ever block the event loop which got me concerned;

Executing slot on every application's event loop iteration

安稳与你 提交于 2019-12-06 07:01:36
问题 How can I call my slot on every iteration of application's event loop? Only way I know is to use QTimer and on every timeout (every millisecond) signal I can call my slot. But I don't like this option, it looks like workaround. Any suggestions how to do this more correctly? 回答1: From the Qt 4.7 QCoreApplication::exec() documentation: To make your application perform idle processing (i.e. executing a special function whenever there are no pending events), use a QTimer with 0 timeout. More

Does calling QDialog::exec in a slot block the main event loop?

泄露秘密 提交于 2019-12-03 15:34:28
My Qt application's main window is a normal QMainWindow subclass. In that window I have a few buttons; each has its clicked signal connected its own slot, and each slot creates a different QDialog like so: void onButtonA_clicked() { MyADialog* dialog = new MyADialog(this); dialog->exec(); delete dialog; } I've been reading this article: https://wiki.qt.io/Threads_Events_QObjects#Events_and_the_event_loop and the author says you should never ever block the event loop which got me concerned; exec is a blocking function, so according to what he says there (his example with Worker::doWork which

PySide wait for signal from main thread in a worker thread

眉间皱痕 提交于 2019-12-01 16:43:40
I decided to add a GUI to one of my scripts. The script is a simple web scraper. I decided to use a worker thread as downloading and parsing the data can take a while. I decided to use PySide, but my knowledge of Qt in general is quite limited. As the script is supposed to wait for user input upon coming across a captcha I decided it should wait until a QLineEdit fires returnPressed and then send it's content to the worker thread so it can send it for validation. That should be better than busy-waiting for the return key to be pressed. It seems that waiting for a signal isn't as straight

PySide wait for signal from main thread in a worker thread

微笑、不失礼 提交于 2019-12-01 15:31:15
问题 I decided to add a GUI to one of my scripts. The script is a simple web scraper. I decided to use a worker thread as downloading and parsing the data can take a while. I decided to use PySide, but my knowledge of Qt in general is quite limited. As the script is supposed to wait for user input upon coming across a captcha I decided it should wait until a QLineEdit fires returnPressed and then send it's content to the worker thread so it can send it for validation. That should be better than

QEventLoop: get time when an event was scheduled

丶灬走出姿态 提交于 2019-12-01 12:12:52
Is it possible to get the time when an event has been scheduled to a QEventLoop (e.g. the QCoreApplication event loop)? I have a situation where the main event loop is paused. When it's reactivated the events are fired and I am interested in the time when the events where added to the queue. The events are not custom events but system (and other) events. Regards, It mainly depends on what are the system events you are interested in, for you have already the timestamp in some cases. As an example, QInputEvent ( base class for events that describe user input , like QMouseEvent , QKeyEvent , and