Navigation

    Qt Forum

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

    • SOLVED Does it make any difference using public slot or private slot?
      General and Desktop • qt5 slot • • deleted286  

      3
      0
      Votes
      3
      Posts
      85
      Views

      @jsulm Thank you
    • SOLVED Why does a functor slot must have exactly the same number of arguments as signal?
      General and Desktop • connect slots slot connect slot • • Xeonacid  

      5
      0
      Votes
      5
      Posts
      195
      Views

      @J-Hilk Thanks! Hope it can be fixed soon. @jsulm Same thanks!
    • UNSOLVED Q Event Loop understanding
      QML and Qt Quick • qml signal slot qeventloop event loop • • texasRanger  

      2
      0
      Votes
      2
      Posts
      123
      Views

      @texasRanger Why do you think you need an additional event loop? From your description I don't see any need for it. If file is changed you will get a signal from file watcher. You just need to make sure parsing of that file does not take too long.
    • UNSOLVED QFileSystemWatcher not working
      QML and Qt Quick • qml qt5 signal slot qmlfilesystemwa • • texasRanger  

      5
      0
      Votes
      5
      Posts
      199
      Views

      Your code shows a lot of ignorance of how Qt works, as they point out, I recommend you read the docs urgently. Here no thread is necessary, it is only necessary to use the Qt event loop. Forget about sequential programming (Qt hates while true since they are not needed). You also do not know what the Qt signals are and how they are used. Also you do not understand the advantages and restrictions of threads, it is not safe to access and modify variables in different threads as you try to do.
    • SOLVED need help SigSegv fault with normal + calculation
      General and Desktop • slot class signals sigsegv fault • • JonnyQB  

      9
      0
      Votes
      9
      Posts
      326
      Views

      @JonnyQB Hi You declare it like Punkte * punkten; Then some place else you must do punkten = new Punkte(); ( not in .h) Often the constructor is a good place.
    • UNSOLVED How to connect to a slot with multiple arguments
      General and Desktop • signal & slot connect slot signalmapper • • hobbyProgrammer  

      13
      0
      Votes
      13
      Posts
      3025
      Views

      Hi, Where do you get that ID ? You'll click on the action, get the ID and then call the slot ?
    • UNSOLVED Connect() uses wrong emitter object.
      General and Desktop • signal connect slot class connection • • Kalado  

      7
      0
      Votes
      7
      Posts
      1751
      Views

      @Kalado said in Connect() uses wrong emitter object.: Look at some code: //A.h class task2 : public QWidget { Q_OBJECT public: task2(QWidget *parent = 0); ~task2(); protected: void mousePressEvent(QMouseEvent *event) override; signals: void myWidgetClicked(); //A.cpp void A::mousePressEvent(QMouseEvent *event){ /// use the respective classname emit myWidgetClicked(); } If ur using Classname as task2 , use void task2::mousePressEvent(QMouseEvent *event){ emit myWidgetClicked(); } Thanks,
    • SOLVED Best way to create new window (QWidget) and interactions between QWidgets
      General and Desktop • qwidget desktop qt4 slot connect slot • • vitorfhcosta  

      4
      0
      Votes
      4
      Posts
      5389
      Views

      difference between exec() and show(), Only QDialog have exec() Qwidgets have show. When you call show on a Dialog, it becomes visible but do not wait for input. example mainw::func() { MyDialog *dia=new MyDialog(this); dia->show(); int a=0; // this code is run the moment dialog is shown on screen, } using exec() mainw::func() { MyDialog dia; dia.exec(); int a=0; // this code is run only after dialog is dismissed. } The version of dialog where u call show() could be called floating so when user click ok it should emit signal that something should happen. ( to maiwindow ) The exec() version will report back the result ok/cancel/closed at once. learn when to use QObject, QWidget, QFrame QWidget is often used if making own widget. QFrame is used if you just need something to draw a frame. If you use Designer you can check out the Widgets that are available. QDialog is useful for any type of windows that pop ups up or open via a menu. I have to set anything inside Register. Yes, Register should be able to give the data back. the widgets inside are private so you need a function to return the data. You might also need to call http://doc.qt.io/qt-5/qdialog.html#accept in your Register buttons clicked slot.
    • UNSOLVED QTcpSokcet connected() signal not fired
      General and Desktop • signal connect slot qtcpsoket • • diverger  

      8
      0
      Votes
      8
      Posts
      3481
      Views

      @jsulm Thanks, I'll give it a try.
    • UNSOLVED Return value from slot in differnet thread
      General and Desktop • thread slot return value • • McLion  

      12
      0
      Votes
      12
      Posts
      9254
      Views

      @VRonin Thanks for your input - there seem to be some misunderstanding. I can not and do not want to wait for the acknowledge of the server as a trigger to sent the next log message - this is against the idea. Log messages need always to be sent, regardless wether the server acknowledges or not - imagine the server even does not acknowledge. Every message sent has an ID# that is incremented by one for every new log message sent. The server acknowledges every message with returning the ID#. Looking at the network of the server with Wireshark and having incoming log messages with time stamps of the same msec - obviously the server has no time to send the acknowledge between incoming protocols. I.e. Sending #1 and # 2 in such a short sequence, obviously when sending #2 the counter for a missed message goes up to one. This is inherit by this system and is by design. Therefore, I'm going to implement a gap of at least a few msec between sending messages. Because the messages are all handled and forwarded in the application by signals / QtEvent queues, I dont have a solid idea so far how to do this. I may have to create a time gated sending queue before handing the messages over to the signal and the QtEvent queue.
    • SOLVED Connect signals with parameters to lambda functions
      General and Desktop • signal slot lambda • • beecksche  

      7
      0
      Votes
      7
      Posts
      5401
      Views

      @kshegunov said: the way the API is organized is a bit different from QTcpSocket You're right. I was also a little bit confused, when i used the QSerialBus module the first time (see my topic https://forum.qt.io/topic/65572/qmodbusmaster-example). Like i said, i think you can built your own class by inherit from QModbusDevice to have a synchronous API. The QSerialBus module is marked as technical preview in Qt 5.6, maybe they add some new functions in future releases similar to QTcpSocket like waitForConnected etc.
    • UNSOLVED QProcess doesn't emit finished signal when script completes its execution
      General and Desktop • qprocess slot finished return zombie • • diredko  

      9
      0
      Votes
      9
      Posts
      6587
      Views

      Hi, Thanks for your response. The whole body of code is proprietary so I'm not sure I can share it in a public forum. However I can make a note that it used to work fine a month ago and after that no changes occurred to this code and no qt libraries were replaced, so the issue is like to be caused by hardware malfunction. Thanks again ))
    • SOLVED How to get a slot when a row of a QTableWidget is clicked ?
      General and Desktop • qtablewidget signal slot clicked • • cxam  

      5
      0
      Votes
      5
      Posts
      4135
      Views

      @mrjj Thanks :)
    • UNSOLVED QStackedWidget setCurrentIndex slot not showing on Signals&Slots editor (QtCreator)
      General and Desktop • qtcreator signal & slot slot qstackedwidget • • cxam  

      15
      0
      Votes
      15
      Posts
      5489
      Views

      @mrjj Hi! I managed to make everything just as I wanted, everything is going fine. The code example you sent me really did the trick. Thanks a lot.
    • SOLVED Slot default parameter generates error
      General and Desktop • slot default argumen • • michelson  

      4
      0
      Votes
      4
      Posts
      847
      Views

      Hi, On a side note, there's no need to use fromStdString to initialize a QByteArray with a string.
    • UNSOLVED Call Slot only when process finished the last time?
      General and Desktop • slot signals loop process • • Opa114  

      3
      0
      Votes
      3
      Posts
      829
      Views

      @Chris-Kawa yes that is an option, but what if erros appear while the processes running? If i put the MessageBox after the for-loop i need a mechanism to check if there was an error or not. therefore i wanted to use Signal and Slot for the process. EDIT i solved it. I wrote a function in which i check if there where errors with readAllStandardError and if the size of it is zero, no error appeared and the show the message box.
    • SOLVED Initialize child object to abstract class - not found slot present in child
      General and Desktop • c++11 slot connection • • ketjow  

      4
      0
      Votes
      4
      Posts
      1940
      Views

      Thx so much @kshegunov , I had Q_OBJECT in abstract class, but I forgot to put it as well in derived class. This solve my problem :) As a side note: I saw several times in the forums here that people are not declaring their overrides as virtual, this is syntactically correct, but I would suggest doing it (makes the code more readable) or even better is to use C++11's override specifier. Thx for this tip so much, I like this kind of notes which helps me improve the code. Yeah you're ride it looks more readable right now :) Parent public slots: virtual void itemToAdd(AbstractFood* item)=0; Child: public slots: void itemToAdd(AbstractFood* item) override; void pizzaToCustomize(Pizza *pizza); and we exactly know what was overriden from parent. Many thx
    • [SOLVED]Signal to and from my qml file
      QML and Qt Quick • signal slot • • ealione  

      6
      0
      Votes
      6
      Posts
      1908
      Views

      @SGaist you are right, I was not receiving anything from qml so my container was empty.
    • Slot and Qbytearray
      General and Desktop • qbytearray slot • • Gillou_beginqt  

      4
      0
      Votes
      4
      Posts
      1335
      Views

      Not every member function needs to be a slot. If it produces some value it doesn't sound very slottish. Consider you have a slot like QByteArray MyClass::saveData() and you connect it to some button: connect(button, &QPushButton::clicked, myObject, &MyClass::saveData). You can connect it that way but where would the byte array data go? Button is certainly not gonna do anything with it. Instead something like this seems more reasonable: class MyClass { ... public slots: //could be private or whatever void processPictureData() { savePictureData(loadPictureData()); } void savePictureData(const QByteArray& data) { /* write the data to some storage thing place */ } public: //could be private or whatever, but it's not a slot QByteArray loadPictureData() { // it could even be made static member to allow greater reusability /* do what you did and return the data */ } } Now you have a nice modular design, each piece of functionality reusable in isolation and hermetic. You can connect either of the slots to some signal. Btw. as the help in the footer suggests please use ``` around your code, not @.
    • How to know if the main window of my program was resized
      General and Desktop • signal slot main window • • darkp03  

      1
      0
      Votes
      1
      Posts
      815
      Views

      Hi, Fortunately for you Qt is very intuitive that way : you just have to implement the resizeEvent method.
    • Qt Signal not Emitting on Second Time
      General and Desktop • signal slot qt 5 • • haris123  

      4
      0
      Votes
      4
      Posts
      1960
      Views

      Are you sure the signal isn't getting emitted or is it a getting emitted but the sendmail object isn't picking it up? My guess is your send mail object is doing something (locked up and never going back to the event loop). So it is never receiving that second message since it never gets back to the event loop. Don't know for sure without seeing the code for it, but just something I've noticed in thread programming with Qt. You could gdb to break into the application and see what your thread is doing. If it isn't in processEvents() that is probably the issue. Oh and one more thing, you can easily test the emitter by create a fake sendmail object with that same slot, then just have it write to the console when it sees that signal. That way you know if is doing nothing but writing to the console and exiting the slot so there won't be any hang ups. My guess is it will work and that your problem lies in the sendmail object. [edit]: added more ideas :)
    • tableView update content
      General and Desktop • tableview signal update slot • • cpuin  

      11
      0
      Votes
      11
      Posts
      5305
      Views

      Since you switched to QSqlTableModel, are you using it's functions to add new rows ?
    • Connecting signals and slots with different parameters: Is it possible?
      General and Desktop • signal & slot signal connect slots slot • • Jorge  

      3
      0
      Votes
      3
      Posts
      5028
      Views

      Hi, Short answer: no The slot signature must either have the same number or less parameters than the signal and the type must be the same.
    • [SOLVED] Slot without Q_OBJECT
      General and Desktop • signal qobject slot template • • qtacc32  

      3
      0
      Votes
      3
      Posts
      2397
      Views

      Qt developers have investigated this before, and there is a partially-working patch. There are still a number of important challenges to work through, but devs are focussing on other things at the moment. It is not currently being actively worked on: http://comments.gmane.org/gmane.comp.lib.qt.devel/10327
    • [SOLVED] How to move a widget in a gridlayout
      General and Desktop • qwidget qpushbutton slot qgridlayout • • RDiGuida  

      7
      0
      Votes
      7
      Posts
      6290
      Views

      Thank you, I had a bit of a read around signal mappers and they seem like the perfect tool for what I need.
    • [SOLVED]Error while using signal slots with arrays.
      General and Desktop • signal slot • • ealione  

      3
      0
      Votes
      3
      Posts
      1171
      Views

      Hi sneubert, No I had forgotten to add that.
    • [SOLVED] Monitoring an object changed asynchronously by a Callback function
      General and Desktop • signal static slot callback • • sirop  

      11
      0
      Votes
      11
      Posts
      4271
      Views

      @SGaist Thanks. Now I have a more clear picture about signals.
    • self.sender() always None
      Language Bindings • signal slot • • elveatles  

      3
      0
      Votes
      3
      Posts
      2238
      Views

      What's weird is I tried the same code again today, but I'm getting the sender this time. Something is not right with how PySide passes the sender, but I can tell this is one of those bugs that will be really hard to track down since it's really inconsistent. Here's a simplified version of what I'm working with: import sys from PySide.QtCore import * from PySide.QtGui import * class CustomDialog(QDialog): def __init__(self, parent=None): super(CustomDialog, self).__init__(parent) self.setLayout(QVBoxLayout()) self.table = QTableWidget() self.table.setColumnCount(2) self.layout().addWidget(self.table) self.table.setRowCount(10) for row in xrange(self.table.rowCount()): item = QTableWidgetItem(str(row)) self.table.setItem(row, 0, item) combo = QComboBox() combo.addItems(['one', 'two', 'three']) combo.currentIndexChanged.connect(self.onIndexChanged) self.table.setCellWidget(row, 1, combo) @Slot(int) def onIndexChanged(self, index): print self.sender() def main(): app = QApplication(sys.argv) dialog = CustomDialog() dialog.show() app.exec_() if __name__ == '__main__': main() If you don't get the bug, I wouldn't spend too much time looking into it, but I appreciate the help.
    • QThread updating a Widget in the GUI
      General and Desktop • qthread signal slot • • sleroux  

      7
      0
      Votes
      7
      Posts
      11176
      Views

      As @Dyami-Caliri said your program is not using the thread at all. You are calling both generateCoordinates() and repaint() in the ui thread. There's no parallel execution here.
    • QML Connections element works under ApplicationWindow and TabView but does not work in Tab section.
      QML and Qt Quick • qml signal slot • • a.toraby  

      2
      0
      Votes
      2
      Posts
      1262
      Views

      Hi, Tabs are lazily loaded. Have you made sure it is loaded already when you expect the signal ? See following example: import QtQuick 2.4 import QtQuick.Controls 1.1 Rectangle { width: 200 height: 200 visible: true Button { id: button z:1 anchors.bottom: parent.bottom anchors.right: parent.right text: "Press Me" } TabView { id: tabview anchors.fill: parent Tab { title: "Tab1" } Tab { title: "Tab2" Connections { target: button onClicked: console.log("Button Pressed") } } } }
    • Pointers With Signals and Slots
      General and Desktop • layout signal slot pointers • • Bolt2strike  

      6
      0
      Votes
      6
      Posts
      1410
      Views

      Yes that was it. You slot looks good. For that second task you can use QSignalMapper)
    • [Solved] Signal & Slot among QML Items / Components
      QML and Qt Quick • signal slot • • myQtQml  

      11
      0
      Votes
      11
      Posts
      11944
      Views

      I could connect by changing the target of Connections dynamically in loader.