Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Newbie 'ish Signals & slots
Forum Updated to NodeBB v4.3 + New Features

Newbie 'ish Signals & slots

Scheduled Pinned Locked Moved Solved General and Desktop
1 Posts 1 Posters 351 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • MikePM Offline
    MikePM Offline
    MikeP
    wrote on last edited by
    #1

    I have successfully used signals to communicate between a main module and a GUI module as per the first code snippets, now I need to do the same but in reverse, GUI to main. I have tried several variants of the second code snippets but without success. Does anybody have a definitive working example of how this can be achieved, thanks.

    
    Main module, working version
    
    class measure(QtGui.QMainWindow, Ui_measWindow):
    
        # create signal for button press processing
        keyUpd = QtCore.pyqtSignal()
        
        def __init__(self):
            super(self.__class__, self).__init__()
            self.ui = Ui_measWindow()
            setConfig()
            self.setupUi(self)
            self._timer = QtCore.QTimer(self)
            self._timer.timeout.connect(self.play)
            self._timer.start(30)
            self._timer = QtCore.QTimer(self)
            self._timer.timeout.connect(self.chkBtns)
            self._timer.start(1000)
            self.update()
    
    GUI module
    
    class Ui_measWindow(object):
    
        def setupUi(self, measWindow):
            measWindow.setObjectName(_fromUtf8("measWindow"))
            measWindow.resize(xWin, yWin)
            measWindow.setWindowTitle(_fromUtf8("Measure"))
            measWindow.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedKingdom))
            self.centralwidget = QtGui.QWidget(measWindow)
            self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
            self.videoFrame = QtGui.QLabel(self.centralwidget)
            self.videoFrame.setGeometry(QtCore.QRect(0, 0, xCam, yCam))
            self.videoFrame.setObjectName(_fromUtf8("videoFrame"))
            self.txtLabel = QtGui.QLabel(self.centralwidget)
            self.txtLabel.setGeometry(QtCore.QRect(20, 32, 180, 50))
            self.txtLabel.setStyleSheet("QLabel {color : cyan}")
            self.txtLabel.setObjectName(_fromUtf8("txtLabel"))
            self.MainWindow = measWindow
            self.center()
    
            <SNIP>
            
            measWindow.setCentralWidget(self.centralwidget)
            self.keyUpd.connect(self.updPos)
    
    Main module, non-working version
    
    class Mini1D(QtGui.QMainWindow, Ui_miniWindow):
    
        self.serUpd.connect(self.serTst)
    
        def __init__(self):
            super(self.__class__, self).__init__()
            self.ui = Ui_miniWindow()
            setConfig()
            self.setupUi(self)
            self._timer = QtCore.QTimer(self)
            self._timer.timeout.connect(self.play)
            self._timer.start(30)
            start_new_thread(flash,(110.0,10.0))
            self.update()
    
        def serTst(self):
            # return ID for S2 is export-80 as per GPIO
            # return ID for S0 is -1 although still active
            serial = wpi.serialOpen('/dev/ttyS2', 9600)
            print(str(serial))
            wpi.serialPuts(serial, "test")
            wpi.serialPutchar(serial, 16)
            wpi.serialClose(serial)
    
    GUI module
    
    class Ui_miniWindow(object):
    
        # create signal for menu processing
        serUpd = QtCore.pyqtSignal()
        
        def setupUi(self, miniWindow):
            miniWindow.setObjectName(_fromUtf8("miniWindow"))
            miniWindow.resize(xWin, yWin)
            miniWindow.setWindowTitle(_fromUtf8("Mini1D"))
            miniWindow.setLocale(QtCore.QLocale(QtCore.QLocale.English, QtCore.QLocale.UnitedKingdom))
            self.centralwidget = QtGui.QWidget(miniWindow)
            self.centralwidget.setObjectName(_fromUtf8("centralwidget"))
            self.videoFrame = QtGui.QLabel(self.centralwidget)
            self.videoFrame.setGeometry(QtCore.QRect(0, 0, xCam, yCam))
            self.videoFrame.setObjectName(_fromUtf8("videoFrame"))
            self.txtLabel = QtGui.QLabel(self.centralwidget)
            self.txtLabel.setGeometry(QtCore.QRect(20, 32, 180, 50))
            self.txtLabel.setStyleSheet("QLabel {color : red}")
            self.txtLabel.setObjectName(_fromUtf8("txtLabel"))
            self.MainWindow = miniWindow
            self.center()
    
    //your code here
    
    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved