qthread

place external live video frames from non supported V4L file into Gstreamer Qt , C++ Qthreads

谁都会走 提交于 2019-12-22 13:32:09
问题 OS : Ubuntu 14.04 SDK : Qt GStreamer : > 1.0 I am wondering how would I put continuously captured frames from a non supported V4L camera into GStreamer. Actually my task is to grab frames from the camera and use only GStreamer to send them to different computer via UDP. But at the moment, I just want to display it on my machine. What I did so far: a) Implemented code in Qt for an IDS camera that captures frames and displays then on Qt as live streaming. b) Separately, I have written ( or

Modifying QStandardItemModel from non-UI QThread?

爱⌒轻易说出口 提交于 2019-12-22 11:46:10
问题 I have Qt4 app which binds QStandardItemModel to the QListView and have the model updated from background/non-UI thread. Sometimes, when the QStandardItem 's setText(..) method is called very repeatedly from the non-UI thread, the application will crash at a la dataChanged(..) handler. I can reproduce the issue by calling setText("xxxxx") repeatedly in a for loop. In my app, the data is read from network hence I update the model in separate, non-UI thread. Is this a common pb? If I understand

Passing QVector<float> from worker thread to main thread via signal/slot

元气小坏坏 提交于 2019-12-22 09:46:22
问题 Currently I have some troubles passing a QVector between to threads. At the moment I have a main thread (GUI-Thread) and an worker thread that emits frequently QVector arrays. Directly before emitting the data inside the vector looks good. The receiver is a slot in the main thread but the Data received in by the slot is garbled. Here are some parts of my code: Emit in the worker thread: void Pipeline::process { QVector<float> buffer(w * h * d); // filling the vector with RGB-Values emit this-

Want to put a method into a QThread

血红的双手。 提交于 2019-12-21 23:20:02
问题 How to add a method within the class to a thread to execute? I do not want to put "Pup" into a seperate class that inherits QThread as this is just an abstraction of some Legacy code I am working on. void Dog::Pup() { printf("pup"); } void Dog::Init() { QThread *dogThread = new QThread(); Pup->moveToThread(dogThread); //this is all wrong Pup->connect(dogThread, ?, Pup, SLOT(Pup), ?) dogThread.start(); } 回答1: Try this: void Dog::Init() { QThread *dogThread = new QThread; connect(dogThread,

PyQt5 - QThread: Destroyed while thread is still running

人走茶凉 提交于 2019-12-21 20:18:32
问题 I am trying to figure out why this code crashes if I try to run the threads for a second time once they are completed. The first time I click "Start 5 Threads" It runs just fine and finishes. But if I click it again. The entire program crashes and I get the QThread: Destroyed while thread is still running Error This code was found on the web. I am trying to learn from it. import time import sys from PyQt5.QtCore import QObject, QThread, pyqtSignal, pyqtSlot from PyQt5.QtWidgets import

Correct way of threading in Qt

半腔热情 提交于 2019-12-21 12:43:28
问题 I have time consuming image loading (image is big), also some operations on it are done when loading. I do not want to block application GUI. My idea is to load image in another thread, emit signal that image is loaded and then redraw view with this image. My approach: void Window::loadImage() { ImageLoader* loaderThread = new ImageLoader(); connect(loaderThread,SIGNAL(imageLoaded()),this,SLOT(imageLoadingFinished()); loaderThread->loadImage(m_image, m_imagesContainer, m_path); } void Window:

Using a QThread in PyQT for serial communication (w. pyserial)

眉间皱痕 提交于 2019-12-21 05:05:19
问题 I am pretty much a beginner when it comes to GUI programming. I am using QT in combination with python bindings (PyQT4). What I am trying to do: Setting up a QThread to read from & write to a Serial Port with pyserial. The main application should be able to emit new serial data via a signal to the running QThread . and receive serial data from the QThread with a signal. I started my own test implementation based on this code (Link). Prior to this I read the basics about QThread s and tried to

How to send a Qt signal containing a cv::Mat?

巧了我就是萌 提交于 2019-12-21 04:24:10
问题 In short, I get following error: QObject::connect: Cannot queue arguments of type 'cv::Mat' (Make sure 'cv::Mat' is registered using qRegisterMetaType().) What I'm trying to do is send a signal containing two cv::Mat images from a QThread to the main thread, so that I can display the output. There's no compile time error, but when I run the program, it gets stuck at a breakpoint in qglobal.h ( inline void qt_noop() {} ). I've tried to add Q_DECLARE_METATYPE(cv::Mat) to the code, to no avail.

Qt/C++在子线程执行函数的两种方法

怎甘沉沦 提交于 2019-12-20 11:34:23
前言: 很多时候,我们的某个函数非常耗时,会造成系统卡顿,但这个函数又不会经常调用,如果另外建立一个线程类,又得去维护,得不偿失,这个时候,我们就希望在子线程执行该函数,执行完自动释放。 这里介绍两个方法: 1、使用QtConcurrent QtConcurrent 是命名空间 ( namespace ),它提供了高层次的函数接口 ( APIs ),使所写程序,可根据计算机的 CPU 核数,自动调整运行的线程数目。 1.1、 函数原型 QFuture<T> QtConcurrent::run(QThreadPool::globalInstance(), function, ...) ; QFuture<T> QtConcurrent::run(QThreadPool *pool, Function function, ...); 1.2、使用准备 使用 QtConcurrent 需要在.pro文件增加 QT += concurrent 如果是使用 VS+Qt ,则需要增加模块 Concurrent 1.3、实例 #include <QString> #include <QDebug> #include <QThread> #include <QApplication> #include "qtconcurrentrun.h" using namespace QtConcurrent

How to plot on my GUI

孤者浪人 提交于 2019-12-20 10:38:06
问题 I'm designing a GUI with PyQt where I need to display a matplotlib/pylab window when I click on a button that makes the plot of the data from a function I've created. It's like a runtime used in Matlab. I want to keep the matplotlib/pylab window as my window everytime I press that button. 回答1: Here is a basic example that will plot three different samples using a QThread : #!/usr/bin/env python #-*- coding:utf-8 -*- import random from matplotlib.backends.backend_qt4agg import