signals-slots

How do I find out if a goroutine is done, without blocking?

。_饼干妹妹 提交于 2019-12-23 08:30:11
问题 All the examples I've seen so far involve blocking to get the result (via the <-chan operator). My current approach involves passing a pointer to a struct: type goresult struct { result resultType; finished bool; } which the goroutine writes upon completion. Then it's a simple matter of checking finished whenever convenient. Do you have better alternatives? What I'm really aiming for is a Qt-style signal-slot system. I have a hunch the solution will look almost trivial ( chan s have lots of

connecting signal/slot across different threads between QObjects

天大地大妈咪最大 提交于 2019-12-23 03:57:13
问题 I wanted to know what is the best practice to connect signal/slots between two QObjects created in the contructor of MainWindow but moved to different threads later...default connections seems not working then when I connect with the option Qt::Directconnection things start working...but sometimes the signal/slot fails...following is my code pattern..please let me know if I need to change my class design... MainWindow.cpp MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), {

connecting signal/slot across different threads between QObjects

流过昼夜 提交于 2019-12-23 03:57:06
问题 I wanted to know what is the best practice to connect signal/slots between two QObjects created in the contructor of MainWindow but moved to different threads later...default connections seems not working then when I connect with the option Qt::Directconnection things start working...but sometimes the signal/slot fails...following is my code pattern..please let me know if I need to change my class design... MainWindow.cpp MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), {

PySide emit signal causes python to crash

柔情痞子 提交于 2019-12-23 03:32:12
问题 I am working through the book "Rapid Gui Programming with Python and Qt" and am having a problem on the signals/slots project. I have downloaded the authors code to compare against my own, and it all looks the same, however, when I emit a signal from a derived spin box class, python just crashes. Here is the entire code that I have: import sys from PySide.QtCore import * from PySide.QtGui import * class ZeroSpinBox(QSpinBox): zeros = 0 def __init__(self, parent=None): super(ZeroSpinBox, self)

Qt - Connect slot with argument using lambda

萝らか妹 提交于 2019-12-23 02:53:26
问题 I have a couple of widgets that will be connected to a single function which required extra arguments. I found that I can use a lambda function in place to pass the function some arguments. The problem is the arguments are getting replaced in the loop and the lambda function is passing only the last one set. Heres what I got: self.widgets is a dictinary with keys for the group of buttons, to make it short let's say it have 2 buttons[QToolButton], linked to their keys: 'play' and 'stop'. def

Slim c++ signal / event mechanism with move semantics for slots

爷,独闯天下 提交于 2019-12-23 02:16:15
问题 I am trying to design a signal and slot system in c++. The mechanism is somewhat inspired by boost::signal but should be simpler. I am working with MSVC 2010 which means that some c++11 features are available but sadly variadic templates are not. First, let me give some contextual information. I implemented a system for processing data that is generated by different hardware sensors connected to the pc. Every single hardware sensor is represented by a class that inherits from a generic class

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-

Keeping the GUI separate

血红的双手。 提交于 2019-12-22 08:42:16
问题 I have a program that (amongst other things) has a command line interface that lets the user enter strings, which will then be sent over the network. The problem is that I'm not sure how to connect the events, which are generated deep inside the GUI, to the network interface. Suppose for instance that my GUI class hierarchy looks like this: GUI -> MainWindow -> CommandLineInterface -> EntryField Each GUI object holds some other GUI objects and everything is private. Now the entryField object

How to use template types as slot and signal parameters in multiple threads?

时光总嘲笑我的痴心妄想 提交于 2019-12-22 05:26:21
问题 Can I use a template type in any way as a slot or signal argument? As an example, I'm trying to define the following: void exampleSignal(std::map<non_template_type_1,non_template_type_2> arg); void exampleSlot(std::map<non_template_type_1,non_template_type_2> arg); This results in the following during runtime: QObject::connect: Cannot queue arguments of type 'std::map<non_template_type_1,non_template_type_2>' (Make sure 'std::map<non_template_type_1,non_template_type_2>' is registered using

How to bind to a signal from a delegate component within a ListView in QML

允我心安 提交于 2019-12-22 04:55:26
问题 Let's say I have a ListView of clickable delegate components (or GridView or Repeater ). These delegate components need to emit a signal along with custom data when triggered that can be picked up by the parent of the ListView . How can this signal binding be achieved? e.g. The following code is my attempt but I don't know how to bind the trigger signal of the delegate component to the componentTriggered signal in the root item? Item { id: root anchors.fill: parent signal componentTriggered