FAQ Database Discussion Community


Can't emit signal in QML custom Item

qt,qml,signals-slots
I created my own Item with signal clicked, that contatins MouseArea. I want to emit signal clicked, when MouseArea is clicked. But nothing works. Here is my .qml code: import QtQuick 2.4 Item { id: baseButton property alias text: txt.text width: txt.width height: txt.height signal clicked onClicked : console.log("Clicked!") Text...

qt 'emit' signal not working properly

c++,qt,signals-slots,emit
I have a class called dosecalibration which contains dosecalibration.cpp and dosecalibration.h. The class is associated to a separate ui form. On the form when a button is clicked a signal is emitted. There is a connection within main window to receive this signal, however it doesn't seem to be working....

Calling a C++ function from Qt (slot does not work)

c++,qt,signals-slots
I have written a client-server program in c++. Now I have to use QT to create the interface. I have created a login interface. When I click login button, it should call the sendmessage function, which sends the username and password to a server (Also written in C++) which verifies...

How to connect signal to boost::asio::io_service when posting work on different thread?

c++,multithreading,boost,boost-asio,signals-slots
I'm trying to use a boost::lockfree queue to manage tasks. These tasks retrieve data and would be processed on a worker thread. Once data is retrieved, a signal should be sent to the main thread with the data. The worker thread is spawned at the start of the application and...

How to close Pyqt5 program from QML?

qt,python-3.x,qml,signals-slots,pyqt5
I started a project in Qt Creator initially with a C++ backend, but then switched it to use PyQt5. I have a main.qml, where when I press a button called Exit, I call Qt.quit(). However, I get a General Message stating: Signal QQmlEngine::quit() emitted, but no receivers connected to handle...

Syntax sugar for signal slot

c++,c++11,signals-slots
Recently I searched internet for good signal-slot library and wonder why on Earth we need such a cumbersome syntax for connecting member methods to signals? Usually we have to write something like this: mySignal.connect(&MyClassName::myMethodName, this); or like that: mySignal += std::bind(&MyClassName::myMethodName, this, std::placeholders::_1); There is obvious duplication and unnessesary typing....

Cross-thread signal slot, how to send char *

c++,multithreading,qt,signals-slots
I've created a simple Qt GUI App and I've created a simple thread in it using worker and worker thread (see below codes, it is a simple code which will be used in a large program). In this program when I push the push button, the thread is created and...

Qt:signal slot pass by const reference

c++,qt,pass-by-reference,signals-slots,pass-by-value
Many qt examples did the following things: signal: passByConstRef(const QImage &) slot: receivedByConstRef( const QImage &) They are connected through queued connection in different threads. In thread 1: {QImage image; image = fromData(...); emit passByConstRef(image); } In thread 2: receivedByConstRef(const QImage& image){ ... pixmap = fromImage(image); ... } Since the...

How to execute a function in Qt when a variable changes its value in the QML?

c++,qt,signals,signals-slots
error: no matching function for call to 'SimulationMode::connect(QString&, const char*, SimulationMode* const, const char*)' QObject::connect (m_standingAgvID, SIGNAL (f(int)), this, SLOT (d(int))); Here, m_standingAgvID is an object of a QString variable which is also used in the Q_PROPERTY. f(int) and d(int) have been defined and declared in the respective signal and...

C++: Thread Safety in a Signal/Slot Library

c++,multithreading,thread-safety,signals-slots
I'm implementing a Signal/Slot framework, and got to the point that I want it to be thread-safe. I already had a lot of support from the Boost mailing-list, but since this is not really boost-related, I'll ask my pending question here. When is a signal/slot implementation (or any framework that...

Dynamic mapping of all QT signals of one object to one slot

c++,qt,signals-slots
I want to connect all signals of one QObject to a certain slot. The slot looks something like this: void SignalIntercepter::signalFired() { std::cout << "Signal is fired!" << std::endl; } The following code is where the QObject will be passed to: void SignalIntercepter::handleObject(QObject* object) { const QMetaObject *me = object->metaObject();...

Qt/C++ how to wait a slot when signal emitted

c++,multithreading,qt5,signals-slots
I have developed an app in Qt/C++, I have used signal/slot mechanism to interact between 2 threads. the first thread run the UI/TreeWidget and the second one run the framework I got an issue on one action. In the UI side, before starting my action, I'm connect signal/slot between UI...

Qt: Connect inside constructor - Will slot be invoked before object is initialized?

c++,qt,event-handling,signals-slots
I am learning Qt framework (C++) and was wondering if QT has any mechanisms to protect slots from being called before an object is fully initialized. Consider Class A constructor: A::A() { mTreeView = new QTreeView(); ... connect(mTreeView, &QTreeView::customContextMenuRequested, this, &A::OnContextMenuRequested); ... } My worry is the user would be...

PyQt5: one signal comes instead of two as per documentation

python,pyqt,python-3.3,signals-slots,pyqt5
I have been reading the section "Connecting Slots By Name" on this PyQt5 documentation page which basically describes new signals and slots functionality. This piece caught my eye: For example the QtGui.QSpinBox class has the following signals: void valueChanged(int i); void valueChanged(const QString &text); When the value of the spin...

connecting signals and slots with different relations

c++,qt,connect,signals-slots
First of all I'd say I'm a noob to GUI programming. I use Qt 5.4. I came up with this code while watching voidRealms videos. connect(ui->horizontalSlider,SIGNAL(sliderMoved(int)),ui->progressBar,SLOT(setValue(int))); Obviously this connects slider movement with progressbar fill. This actually works like progressbarfill <- slidermovement. How can I make into a different relation? Like...

Cannot connect (null)::selectionChanged to QTableView

c++,qt,qt-creator,signals-slots,qtableview
I have the following promoted QTableView: class QRightClickableTableView : public QTableView { Q_OBJECT public: explicit QRightClickableTableView(QWidget *parent = 0): QTableView(parent) {} private slots: void mouseReleaseEvent(QMouseEvent *e) { if(e->button()==Qt::RightButton) emit rightClicked(); else if (e->button()==Qt::LeftButton) emit leftClicked(); } signals: void rightClicked(); void leftClicked(); }; When binding the selectionChanged signal of QRightClickableTableView, but...

Attempting to read stdout from spawned QProcess

qt,signals-slots,qprocess
I've written a Qt application to create a UI to a backend Linux console application. Now, I want the console output and the standard error to be displayed in a window in my application. I've tried the following code : int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow...

How to resolve 2 sequential calls on Qt slot and perform action only once

c++,qt,lambda,signals-slots,qt-signals
I have a CodeEditor class which inherits from QPlainTextEdit. This class has to emit requests when textCursor()'s position or selection changes. The thing is, I don't want 2 calls to assembleIntellisenseRequest and pickListSortRequest signals when both cursorPositionChanged and selectionChanged is emitted. I solved this with adding bool update_ member to...

How often are objects copied when passing across PyQt signal/slot connections?

python,pyqt,signals-slots,pyqt5
This interesting article evaluates how often are objects copied when passed across signal/slot connections in Qt. Basically, the outcome is that when passed by const reference in C++, objects are either not copied at all (for direct connections) or copied once (for queued connections). How about PyQt? Does the same...

Qt app receives HUP signal unexpectedly when forked to background

qt,signals,fork,daemon,signals-slots
I have built a Qt app which upon receipt of the HUP signal shuts down nicely (setup like this how to get signals into Qt). This works great under Red Had 6, but when I run this app under Ubuntu 14 my app receives the HUP signal immediately (after forking...