我尝试将spinbox的值和复选框的状态从第二个对话框发送到父对话框....但返回的值不是第二个对话框中的值 这里是代码
import sys
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
__appname__ = 'Dialog app '
class Dialog(QDialog):
def __init__(self, parent=None):
super(Dialog, self).__init__(parent)
self.btn = QPushButton('open dialog')
self.label1 = QLabel('Label 1 Result')
self.label2 = QLabel('Label 2 result')
layout = QVBoxLayout()
layout.addWidget(self.btn)
layout.addWidget(self.label1)
layout.addWidget(self.label2)
self.setLayout(layout)
self.setWindowTitle(__appname__)
self.btn.clicked.connect(self.dialogOpen)
def dialogOpen(self):
dialog = subDialog()
self.sub = subDialog()
self.check = str(self.sub.checkbox.isChecked())
self.spin = str(self.sub.spinbox.value())
if dialog.exec_():
self.label1.setText('spinbox value is ' + self.spin)
self.label2.setText('Checkbox is ' + self.check)
class subDialog(QDialog):
def __init__(self, parent=None):
super(subDialog, self).__init__(parent)
self.setWindowTitle('Sub Dialog')
self.checkbox = QCheckBox()
self.spinbox = QSpinBox()
self.buttonOK = QPushButton('Ok')
self.buttonCancel = QPushButton('cancel')
lay = QGridLayout()
lay.addWidget(self.spinbox, 0, 0)
lay.addWidget(self.checkbox, 0, 1,)
lay.addWidget(self.buttonOK)
lay.addWidget(self.buttonCancel)
self.setLayout(lay)
self.buttonOK.clicked.connect(self.accept)
self.buttonCancel.clicked.connect(self.reject)
app = QApplication(sys.argv)
form = Dialog()
form.show()
app.exec_()
答案 0 :(得分:4)
问题是您在打开Dialog之前读取了值。这只会给你初始值。打开对话框后放置读数,你会没事的。
SELECT
a.*
, b.status
FROM table a
JOIN (SELECT *, ROW_NUMBER() OVER (PARTITION BY id ORDER BY seq DESC) AS rn
FROM dbo.Table) b ON a.id = b.id AND b.rn = 1
答案 1 :(得分:2)
Map
阻塞,因此您获得的数据是显示新窗口之前的数据,您必须获取关闭窗口的数据,即exec_()
之后的数据:
exec_()