Python PyQt5.QtWidgets 模块,QDateTimeEdit() 实例源码

我们从Python开源项目中,提取了以下11个代码示例,用于说明如何使用PyQt5.QtWidgets.QDateTimeEdit()

项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def createEditor(self, parent, styleOption, index):
        if index.column() == 1:
            editor = QDateTimeEdit(parent)
            editor.setDisplayFormat(self.parent().currentDateFormat)
            editor.setCalendarPopup(True)
            return editor

        editor = QLineEdit(parent)
        # create a completer with the strings in the column as model
        allStrings = []
        for i in range(1, index.model().rowCount()):
            strItem = index.model().data(index.sibling(i, index.column()), Qt.EditRole)
            if strItem not in allStrings:
                allStrings.append(strItem)

        autoComplete = QCompleter(allStrings)
        editor.setCompleter(autoComplete)
        editor.editingFinished.connect(self.commitAndCloseEditor)
        return editor
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def createEditor(self, parent, styleOption, index):
        if index.column() == 1:
            editor = QDateTimeEdit(parent)
            editor.setDisplayFormat(self.parent().currentDateFormat)
            editor.setCalendarPopup(True)
            return editor

        editor = QLineEdit(parent)
        # create a completer with the strings in the column as model
        allStrings = []
        for i in range(1, index.model().rowCount()):
            strItem = index.model().data(index.sibling(i, index.column()), Qt.EditRole)
            if strItem not in allStrings:
                allStrings.append(strItem)

        autoComplete = QCompleter(allStrings)
        editor.setCompleter(autoComplete)
        editor.editingFinished.connect(self.commitAndCloseEditor)
        return editor
项目:alignak-app    作者:Alignak-monitoring-contrib    | 项目源码 | 文件源码
def test_initialize_downtime(self):
        """Initialize Downtime"""

        under_test = DownQDialog()
        under_test.initialize('host', 'my_host', 'Downtime requested by App')

        self.assertTrue(under_test.fixed)
        self.assertTrue(under_test.duration)
        self.assertIsInstance(under_test.duration, QTimeEdit)
        self.assertEqual(under_test.duration_to_seconds(), 14400)
        self.assertTrue(under_test.start_time)
        self.assertIsInstance(under_test.start_time, QDateTimeEdit)
        self.assertTrue(under_test.end_time)
        self.assertIsInstance(under_test.end_time, QDateTimeEdit)
        self.assertEqual(
            under_test.end_time.dateTime().toTime_t() - under_test.start_time.dateTime().toTime_t(),
            7200
        )

        self.assertEqual('Downtime requested by App', under_test.comment_edit.toPlainText())
项目:well-being-diary    作者:SunyataZero    | 项目源码 | 文件源码
def __init__(self, i_unix_time_it, i_parent = None):
        super(DateTimeDialog, self).__init__(i_parent)

        vbox = QtWidgets.QVBoxLayout(self)

        self.date_time_edit = QtWidgets.QDateTimeEdit(self)
        self.date_time_edit.setCalendarPopup(True)
        present_qdatetime = QtCore.QDateTime()
        present_qdatetime.setMSecsSinceEpoch(1000 * i_unix_time_it)
        self.date_time_edit.setDateTime(present_qdatetime)
        vbox.addWidget(self.date_time_edit)

        self.button_box = QtWidgets.QDialogButtonBox(
            QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
            QtCore.Qt.Horizontal,
            self
        )
        vbox.addWidget(self.button_box)
        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)
        # -accept and reject are "slots" built into Qt
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def createEditor(self, parent, styleOption, index):
        if index.column() == 1:
            editor = QDateTimeEdit(parent)
            editor.setDisplayFormat(self.parent().currentDateFormat)
            editor.setCalendarPopup(True)
            return editor

        editor = QLineEdit(parent)
        # create a completer with the strings in the column as model
        allStrings = []
        for i in range(1, index.model().rowCount()):
            strItem = index.model().data(index.sibling(i, index.column()), Qt.EditRole)
            if strItem not in allStrings:
                allStrings.append(strItem)

        autoComplete = QCompleter(allStrings)
        editor.setCompleter(autoComplete)
        editor.editingFinished.connect(self.commitAndCloseEditor)
        return editor
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def setEditorData(self, editor, index):
        if isinstance(editor, QLineEdit):
            editor.setText(index.model().data(index, Qt.EditRole))
        elif isinstance(editor, QDateTimeEdit):
            editor.setDate(QDate.fromString(
                index.model().data(index, Qt.EditRole), self.parent().currentDateFormat))
项目:Mac-Python-3.X    作者:L1nwatch    | 项目源码 | 文件源码
def setModelData(self, editor, model, index):
        if isinstance(editor, QLineEdit):
            model.setData(index, editor.text())
        elif isinstance(editor, QDateTimeEdit):
            model.setData(index, editor.date().toString(self.parent().currentDateFormat))
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def setEditorData(self, editor, index):
        if isinstance(editor, QLineEdit):
            editor.setText(index.model().data(index, Qt.EditRole))
        elif isinstance(editor, QDateTimeEdit):
            editor.setDate(QDate.fromString(
                index.model().data(index, Qt.EditRole), self.parent().currentDateFormat))
项目:examples    作者:pyqt    | 项目源码 | 文件源码
def setModelData(self, editor, model, index):
        if isinstance(editor, QLineEdit):
            model.setData(index, editor.text())
        elif isinstance(editor, QDateTimeEdit):
            model.setData(index, editor.date().toString(self.parent().currentDateFormat))
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def setEditorData(self, editor, index):
        if isinstance(editor, QLineEdit):
            editor.setText(index.model().data(index, Qt.EditRole))
        elif isinstance(editor, QDateTimeEdit):
            editor.setDate(QDate.fromString(
                index.model().data(index, Qt.EditRole), self.parent().currentDateFormat))
项目:pyqt5-example    作者:guinslym    | 项目源码 | 文件源码
def setModelData(self, editor, model, index):
        if isinstance(editor, QLineEdit):
            model.setData(index, editor.text())
        elif isinstance(editor, QDateTimeEdit):
            model.setData(index, editor.date().toString(self.parent().currentDateFormat))