Is there a way to set the QInputDialog().getInt() dialog as a NonModal dialog?
-
This function is convenient. But I need a NonModal dialog, is there a way to let
QInputDialog().getInt() to achieve it? -
This function is convenient. But I need a NonModal dialog, is there a way to let
QInputDialog().getInt() to achieve it?@feiyuhuahuo The static methods using exec so they are modal so a solution in your case is not to use
QInputDialog::getInt()but to implement it:from PySide2 import QtWidgets class MainWindow(QtWidgets.QMainWindow): def __init__(self, parent=None): super().__init__(parent) button = QtWidgets.QPushButton("Open Dialog") self.setCentralWidget(button) self.input_dialog = QtWidgets.QInputDialog(modal=False) self.input_dialog.setWindowTitle("title") self.input_dialog.setLabelText("label") self.input_dialog.setIntRange(-2147483647, 2147483647) self.input_dialog.setIntValue(5) self.input_dialog.setIntStep(1) button.clicked.connect(self.input_dialog.show) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) w = MainWindow() w.show() sys.exit(app.exec_())