Skip to content
  • 0 Votes
    3 Posts
    1k Views
    O

    @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.

  • 0 Votes
    4 Posts
    2k Views
    K

    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

  • 0 Votes
    6 Posts
    2k Views
    ealioneE

    @SGaist you are right, I was not receiving anything from qml so my container was empty.

  • 0 Votes
    4 Posts
    1k Views
    Chris KawaC

    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 @.

  • 0 Votes
    1 Posts
    905 Views
    R

    Hi,

    Fortunately for you Qt is very intuitive that way : you just have to implement the resizeEvent method.

  • 0 Votes
    4 Posts
    2k Views
    A

    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 :)

  • 0 Votes
    11 Posts
    6k Views
    SGaistS

    Since you switched to QSqlTableModel, are you using it's functions to add new rows ?

  • 0 Votes
    3 Posts
    5k Views
    SGaistS

    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.

  • 0 Votes
    3 Posts
    3k Views
    JKSHJ

    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

  • 0 Votes
    7 Posts
    7k Views
    R

    Thank you, I had a bit of a read around signal mappers and they seem like the perfect tool for what I need.

  • 0 Votes
    3 Posts
    1k Views
    ealioneE

    Hi sneubert,
    No I had forgotten to add that.

  • 0 Votes
    11 Posts
    5k Views
    siropS

    @SGaist

    Thanks. Now I have a more clear picture about signals.

  • 0 Votes
    3 Posts
    3k Views
    E

    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.

  • 0 Votes
    7 Posts
    12k Views
    Chris KawaC

    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.

  • 0 Votes
    2 Posts
    1k Views
    p3c0P

    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") } } } }
  • 0 Votes
    6 Posts
    2k Views
    SGaistS

    Yes that was it. You slot looks good.

    For that second task you can use QSignalMapper)

  • 0 Votes
    11 Posts
    14k Views
    M

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