Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. signal & slot
    Log in to post

    • UNSOLVED How to emit Signal from nested QML page (by Loader) to python
      QML and Qt Quick • qtquick signal & slot • • Witc  

      3
      0
      Votes
      3
      Posts
      104
      Views

      You don't. C++ shouldn't connect to QML signals. Expose a slot/invokable function in a Python object that is accessible from QML and call that slot in QML.
    • UNSOLVED PySide6 QML How to connect signals and slots over different class-instances correctly
      Language Bindings • qml python signal & slot pyside6 • • test123-all  

      1
      0
      Votes
      1
      Posts
      381
      Views

      No one has replied

    • UNSOLVED QtDesigner & signal emit on press/etc?
      General and Desktop • signal & slot signal qtdesigner • • Dariusz  

      4
      0
      Votes
      4
      Posts
      127
      Views

      Hi On the bright side, when you do declare forward signals, you are doing it just right as accessing widgets left and right produces hard to maintain code that breaks easily. So by being "forced" to surface the external needed data via signals, you define an interface that will hold, even if you refactor the internal widgets. The rest of the app will remain unaffected. \o/
    • UNSOLVED Connect Signal with Argument via Lambda to Slot with Argument?
      General and Desktop • signal & slot cpp lambda argument • • BDC_Patrick  

      4
      0
      Votes
      4
      Posts
      125
      Views

      @jsulm & @J-Hilk Thank you so much. You´re my Heroes :D Everyday something new to learn :)
    • SOLVED For each QT-Creator one signal emitted
      General and Desktop • signal & slot qt-creator • • firen  

      5
      0
      Votes
      5
      Posts
      220
      Views

      @SGaist I was too sure I guess... :-) Thanks!
    • UNSOLVED How to connect using const char* method?
      General and Desktop • signal & slot qobject • • CJha  

      3
      0
      Votes
      3
      Posts
      134
      Views

      @JonB I understand the usual paradigm, but my code is made in such a way so that the sender object is hidden, and so there is not really any place where header files from both sender and receiver are included simultaneously. This is to maintain modularity in the code. However, by using: connect(this, SIGNAL(testConnection()), receiver, method); in the sender it recognizes that I am trying to connect to Receiver::testConnection() and it has the pointer to the receiver passed to it, then in theory it should be capable of connecting its signal to the receiver's slot with only this much information about the receiver.
    • UNSOLVED read value from combo box to c++ function
      QML and Qt Quick • qml c++ signal & slot signal combobox • • texasRanger  

      5
      0
      Votes
      5
      Posts
      317
      Views

      @texasRanger said in read value from combo box to c++ function: I have been trying to connect the qml signal of the combo box being changed to the itemChanged slot in c++. but I have had no luck. Don't do that. Do like in the link posted by SGaist. Some links about the reason why you shouldn't reach into QML from C++: https://doc.qt.io/qt-5/qtquick-bestpractices.html#interacting-with-qml-from-c http://doc.qt.io/qt-5/qtqml-cppintegration-overview.html#interacting-with-qml-objects-from-c https://youtu.be/vzs5VPTf4QQ?t=23m20s
    • UNSOLVED Signal and Slot with two different UI class in QT
      General and Desktop • qtablewidget signal & slot qt c++ • • Rhutu  

      2
      0
      Votes
      2
      Posts
      438
      Views

      @Rhutu Nothing should "vanish". If you overwrite what is in QTableWidget with something not as you intended then obviously it will cease to show whatever it showed before. If you need to pass additional data from your main window to the slot, you can either do it via a C++ lambda for the slot, or put a slot which is in the main window instead of Obj,SLOT(WriteToFile()), and have that call Obj->WriteToFile(extra). Stop using old-style SIGNAL/SLOT() macros for signals/slots, use https://wiki.qt.io/New_Signal_Slot_Syntax, it's better and it will help you connect correct things.
    • SOLVED Custom sighnal in main window not recognized?
      General and Desktop • signal & slot colordialog custom signal • • BDC_Patrick  

      3
      0
      Votes
      3
      Posts
      183
      Views

      @sierdzio Thank you very much :D
    • SOLVED Stack overflow due to model QProgressDialog::setValue() calls via signal from another thread
      General and Desktop • qthread signal & slot qprogressdialog overflow • • oblivioncth  

      8
      0
      Votes
      8
      Posts
      618
      Views

      Congratulation and thank you for the fix :-)
    • UNSOLVED Why the signal can't be sent to slot after an hour?
      General and Desktop • signal & slot • • Robert_is_not_robot  

      10
      0
      Votes
      10
      Posts
      279
      Views

      @hskoglund No, the connect() statement is in the function OnClickOperate(). And OnClickOperate() is a slot connected to the signal clicked() of QPushButton. So the connect() statement will only be executed when the button was clicked.
    • UNSOLVED Few questions about QThread worker-object model
      General and Desktop • qthread signal & slot pointers cleanup • • oblivioncth  

      1
      0
      Votes
      1
      Posts
      336
      Views

      No one has replied

    • SOLVED Final task upon program termination
      QML and Qt Quick • qml c++ qt5 signal & slot function • • texasRanger  

      3
      0
      Votes
      3
      Posts
      235
      Views

      @fcarney Sweet! That worked, thanks.
    • UNSOLVED Is it possible to notify items in the model without signals?
      General and Desktop • signal & slot qmodelindex abstractlist • • arguskso  

      6
      0
      Votes
      6
      Posts
      360
      Views

      @arguskso said in Is it possible to notify items in the model without signals?: when new data is coming I can emmit signal with an id and all delegates will receive it and one with the corresponding id will send one more signal back to the model with it's index in the model. Delegates are used for displaying, they don't know anything about the internal data structure and don't have really access to anything else except it's own index. This can't work. You have to do it the way @JonB suggested to you.
    • UNSOLVED QFileSystemWatcher fileChanged() signal to QML slot
      QML and Qt Quick • qml signal & slot c++ to qml qfilesystemwatc connect slot • • texasRanger  

      3
      0
      Votes
      3
      Posts
      371
      Views

      Export watcher: int main(int argc, char *argv[]) { QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QGuiApplication app(argc, argv); QQmlApplicationEngine engine; const QUrl url(QStringLiteral("qrc:/main.qml")); QObject::connect(&engine, &QQmlApplicationEngine::objectCreated, &app, [url](QObject *obj, const QUrl &objUrl) { if (!obj && url == objUrl) QCoreApplication::exit(-1); }, Qt::QueuedConnection); QFileSystemWatcher watcher; watcher.addPath("data.json"); readJSON myGlobal; engine.rootContext()->setContextProperty("myGlobalObject", &myGlobal); engine.rootContext()->setContextProperty("watcher", &watcher); engine.load(url); return app.exec(); } and use Connections: Window { visible: true width: 800 height: 800 title: qsTr("Screen Display") DisplaysForm { function callCPP(text) { var dataOne = myGlobalObject.readingJson(text) dataOne = parseFloat(dataOne) return dataOne } function updateDisplay() { var value = callCPP("Engine_Spd") engSpd_txt.text = value var value1 = callCPP("Engine_Power") engPwr_txt.text = value1 } Connections{ target: watcher function onFileChanged(path){ console.log(path) updateDisplay() } } }
    • UNSOLVED Signal inside readyread of QUdpsocket
      General and Desktop • signal & slot threading udp qudpsocket • • Lior  

      7
      0
      Votes
      7
      Posts
      402
      Views

      @Lior said in Signal inside readyread of QUdpsocket: why the UI main thread stoped to respond ? the msleep is in anthor thread. Because you do it wrong (and I would guess the msleep is not in the thread but in the gui thread) but without code...
    • UNSOLVED integrating with QAbstractListModel
      QML and Qt Quick • listview signal & slot • • ahmad98  

      1
      0
      Votes
      1
      Posts
      152
      Views

      No one has replied

    • SOLVED Signals&Slots Error: No matching function for call to 'connect' (requires 3 arguments, but 4 were provided)
      General and Desktop • signal & slot qcustomplot • • TUStudi  

      4
      0
      Votes
      4
      Posts
      966
      Views

      Thank you both, it works now.
    • UNSOLVED Connecting Signals in dynamically created objects to Slots in MainWindow
      General and Desktop • signal & slot mainwindow • • EaccB  

      10
      0
      Votes
      10
      Posts
      958
      Views

      Hi Just as a note. It's also possible to do signal to signal connects. So if MainWindow just needs to know data has changed to reload something then you could also Define new Signal in class A void DataChangedForB and internally when you create the B's, connect B's signal datachanged to A::DataChangedForB signal And then in MainWindow, simply connect Mains slot to the new A::DataChangedForB signal However, if you are using sender() to access the B' instance, this wont work.
    • UNSOLVED Write Scheduler to run different pointer to member
      General and Desktop • signal & slot qt5.6 timer • • Max13  

      7
      0
      Votes
      7
      Posts
      357
      Views

      @chehrlic said in Write Scheduler to run different pointer to member: I still don't see why a QTimer isn't enough - it can be started, stopped, can be run once or more, can execute any function given with any kind of parameters, even a lambda, ... there is nothing your description requires you to store the PMF by your own. But maybe QMetaMethod is something you can take a look on Well, like you said, QTimer alone could be enough at first sight, but if I want to "manage" them, or even organize them, I need a wrapper with some human-readable data. That's when the Task class comes handy. This is my current Task class, as of today: class Task : public QObject { Q_OBJECT public: typedef std::function<bool(QString&)> Function; private: QString m_name; Function m_function; QDateTime m_firstExec; int m_frequency; const Task *m_depends; QDateTime m_lastExec; bool m_lastStatus; QString m_failedReason; QMetaObject::Connection m_dependCnt; public: // Constructors/Getters/Setters signals: void starting(); void finished(bool status); public slots: void schedule(); void exec(); }; I'm stuck with a single type of Function stored (bool (QString&)), with the m_depends property I can wait for another Task to emit finished to effectively call schedule() (when I call schedule(), if there is a dependency, the task waits for the dependency's finished() to be emitted, then it calls schedule() on itself. When schedule() doesn't have to wait for anything, it calls QTimer::singleShot() with exec() as the slot, which itself calls the internal m_function stored. So I'm using a QTimer in the end, but with some extra properties. Except being stuck with a single type of function (I'm storing lambdas for now), I'm pretty happy with that, moreover if I need to build a widget showing the status of each of them. I will look at QMetaMethod also, thanks for your suggestions
    • UNSOLVED How to connect to a slot with multiple arguments
      General and Desktop • signal & slot connect slot signalmapper • • hobbyProgrammer  

      13
      0
      Votes
      13
      Posts
      3790
      Views

      Hi, Where do you get that ID ? You'll click on the action, get the ID and then call the slot ?
    • UNSOLVED Bluetooth Low Energy: State 'ServiceDiscovered' is never reached
      General and Desktop • signal & slot bluetooth bluetooth low e ble • • SpaceToon  

      19
      0
      Votes
      19
      Posts
      1405
      Views

      The QTBluetooth Central API is not supported on any platform. see the first table in Qt Bluetooth
    • SOLVED SLOT is not executed after successfully contected to BLE-Device
      General and Desktop • signal & slot bluetooth ble signals slots • • SpaceToon  

      7
      0
      Votes
      7
      Posts
      478
      Views

      @J-Hilk Thank you, JonB and you were right. For me it actually makes more sense that e.g. at first you connect to the device and then you say "okay, if the signal "connected" is emitted then call the function x.y.". So after changing it, it works now. However, after getting all services and calling "service->discoverDetails" and then "service->characteristics" the characteristics List is empty. After connection is successfull: void Scanner::startServiceDiscovery(){ connect(controller, &QLowEnergyController::discoveryFinished, this, &Scanner::discoveryFinished); controller->discoverServices(); } void Scanner::discoveryFinished(){ qDebug() << "\nService Discovery finished. Following Services found:\n"; QList<QBluetoothUuid> serviceList = controller->services(); for(QBluetoothUuid &sl : serviceList){ qDebug() << controller->createServiceObject(sl)->serviceName() << "Uuid: " << sl; } uartService = controller->createServiceObject(adafruitServiceUuid); qDebug() <<"\nChose the following service: " << (*uartService).serviceName(); connect(uartService, &QLowEnergyService::stateChanged, this, &Scanner::printChars); qDebug() << uartService->state(); //here the state is QLowEnergyService::DiscoveryRequired uartService->discoverDetails(); } void Scanner::printChars(){ qDebug() << uartService->state(); // here the state is now QLowEnergyService::DiscoveringServices const QList<QLowEnergyCharacteristic> chars = uartService->characteristics(); qDebug()<< chars.size(); //however the list size is 0 for (const QLowEnergyCharacteristic &ch : chars) { qDebug() << &ch; } } btw: I know that there is an example for BLE Scanner. But for a project, I want to create an own desktop application which connnects to a peripheral and live plots the data which are received from the sensor with qcustomplot. So I need a QWidget Application because QCustomPlot is a widget...
    • SOLVED QWidget not response on ComboBox action
      General and Desktop • qwidget signal & slot combobox • • nebulaekg  

      4
      0
      Votes
      4
      Posts
      479
      Views

      I said 'Maybe you've a typo...' The problem with auto-connect is that you can not be sure if it is really connected (e.g. when there is a typo somewhere in the functions signature or the ui element name) and it easily breaks (e.g. when renaming an ui element).
    • UNSOLVED Program crash when it loads videos from multiple directories continuously
      General and Desktop • qt creator signal & slot qt5.11 slider • • Kinesis  

      8
      0
      Votes
      8
      Posts
      1012
      Views

      @Kinesis You should delete them when they are not needed anymore
    • SOLVED Click a directory in listWidget and display images on another listWidget
      General and Desktop • signal & slot qt5.5.0 images listwidget • • Kinesis  

      6
      0
      Votes
      6
      Posts
      2089
      Views

      I got the answer. QDir directory = QFileDialog::getExistingDirectory(this, tr("Open Directory"),"/home", QFileDialog::ShowDirsOnly| QFileDialog::DontResolveSymlinks); auto listWidget_images = new QListWidget();//set listwidget to display images listWidget_images->setMinimumSize(1200,400); listWidget_images->setViewMode(QListWidget::IconMode); listWidget_images->setIconSize(QSize(320,240)); listWidget_images->setResizeMode(QListWidget::Adjust); for(const QFileInfo & finfo: directory.entryInfoList()){ ui->listWidget_dirs->addItem(finfo.absoluteFilePath()); } connect(ui->listWidget_dirs, & QListWidget::itemClicked,[listWidget_images,this](QListWidgetItem *item) { listWidget_images->show(); listWidget_images->clear(); QDir directory(item->text()); directory.setNameFilters({"*.png", "*.jpg"}); for(const QFileInfo & finfo: directory.entryInfoList()){ QListWidgetItem *item = new QListWidgetItem(QIcon(finfo.absoluteFilePath()), finfo.fileName()); listWidget_images->addItem(item); } });
    • SOLVED Replicate the contents of the current selected item in QTableView
      General and Desktop • qtableview signal & slot model-view view • • Arthur Araruna  

      7
      0
      Votes
      7
      Posts
      1210
      Views

      @Arthur-Araruna said in Replicate the contents of the current selected item in QTableView: both column and row indices All you need to do is replace currentRowChanged with currentIndexChanged
    • SOLVED How to make signals and slots working in a console application? (Event loop not working)
      General and Desktop • signal & slot event loop • • robro  

      4
      0
      Votes
      4
      Posts
      1964
      Views

      @robro You misunderstood what @VRonin wrote: you should NOT have such loops. Just use signals/slots in your app - there are no differences to UI apps.
    • SOLVED New class --> signal and slots
      General and Desktop • signal & slot connect • • TMJJ  

      7
      0
      Votes
      7
      Posts
      1328
      Views

      @TMJJ I hope you are not going to interpret the output of candump in your application to receive CAN frames! SocketCAN provides a userspace API which can be perfectly used from C/C++ programs. As SocketCAN is open source, there are lots of examples how to do this, like the SocketCAN plugin of QtSerialBus or the source code of candump. Regards
    • SOLVED Blocking Queue Between QThreads
      General and Desktop • signal & slot multi-threading blocking queue • • podkiva  

      6
      0
      Votes
      6
      Posts
      3567
      Views

      @podkiva said in Blocking Queue Between QThreads: P.S. It seems you forgot to call finishProcessing() at the end of process(const Command & cmd) {...}. No, it's not an oversight. I left it for you to call whenever appropriate, as you might be doing some asynchronous operation in process(const Command & cmd), like reading a QProcess output, or reading a socket or w/e. In that case you'd connect the signal signifying the end of that async operation to the mentioned slot to push the next command to be handled.
    • UNSOLVED Qt signal from model item to QML slot
      QML and Qt Quick • qml listview signal & slot • • ionick  

      4
      0
      Votes
      4
      Posts
      1506
      Views

      In this case, the color of the model item is being changed somewhere in the backend You don't require to do this. This is where Model View framework comes into picture. color change should automatically taken care by the model itself. I'm assuming that you have written custom model. Are you sending the dataChanged(..) signal whenever data is changed at model ?
    • SOLVED how to access the signal parameters associated with the QSignalTransition in a lambda
      General and Desktop • signal & slot qstatemachine lamda • • alex_qwa  

      9
      0
      Votes
      9
      Posts
      2325
      Views

      @VRonin : yes, but the system is rather complex and i want to use the statemachine framwork to implement it). By the way this same signal might require other actions in some of the other states Thanks a lot for your time
    • SOLVED Using QSignalMapper instead of Signals and slots
      General and Desktop • qt creator signal & slot qstring qsignalmapper • • Kushan  

      4
      0
      Votes
      4
      Posts
      1087
      Views

      @Kushan Simple C++: class Dialog2 : public QDialog { Q_OBJECT private slots: void receiveValue2 (QString val) public: QString Value explicit Dialog2(QWidget *parent = 0); ~Dialog2(); void setValue(const QString &val) { Value=val; } private: Ui::Dialog2 *ui; }; ... void MainWindow::on_pushButton_clicked() { value=ui->line_Edit->text(); Dialog dialog1; dialog1.setValue(value); }
    • UNSOLVED sending QStringLists from dynamically created buttons using signals and slots
      General and Desktop • qtcreator signal & slot dynamic buttons • • Kushan  

      21
      0
      Votes
      21
      Posts
      4318
      Views

      @SGaist Thanx mate :) Qt rox :D
    • SOLVED qcheckbox SLOT doesnot get called on clicked
      General and Desktop • signal & slot qcheckbox • • Sumit  

      12
      0
      Votes
      12
      Posts
      2476
      Views

      @Sumit Glad u got the result, Happy Coding, Thanks,
    • UNSOLVED Loading QStringList value received from signal slot
      General and Desktop • qtcreator signal & slot combobox constructor • • Lasith  

      6
      0
      Votes
      6
      Posts
      2142
      Views

      Hi If you changed to Dialog::Dialog(QStringList listToLoad, QWidget *parent = 0) ; Make sure to change it both in .h file and .cpp file so they match.
    • UNSOLVED is it necessary to use connection for frequent gui updation ??
      General and Desktop • qtableview signal & slot • • vasu_gupta  

      2
      0
      Votes
      2
      Posts
      666
      Views

      Hi it will only be a problem if you make too long lasting loop. Then it will stop redrawing.
    • UNSOLVED DirectConnection / QueuedConnection : Parallel Execution Problem
      General and Desktop • signal & slot queuedconnectio • • After  

      3
      0
      Votes
      3
      Posts
      1707
      Views

      @After For the reason why Qt::BlockingQueuedConnection does not work for you and gives you the error message, from the manual page @SGaist references: Same as Qt::QueuedConnection, except that the signalling thread blocks until the slot returns. This connection must not be used if the receiver lives in the signalling thread, or else the application will deadlock. It's for use across different threads for emitter/receiver, only.
    • SOLVED How to wait in a slot?
      General and Desktop • signal & slot event loop • • tmp15711  

      11
      0
      Votes
      11
      Posts
      3947
      Views

      And then you should maybe consider creating a widget to handle your threads requests for input one after the other or grouped. Whatever makes sense for your application.