pyqt4在Linux中设置QDateEdit值

时间:2016-08-22 16:17:44

标签: python linux pyqt4

我在启动对话框之前在对话框中将日期值从表复制到QDateEdit。当我这样做时,日期格式从" yyyy-MM-dd"到" dd / MM / yy"在对话框中。这种情况发生在Linux而非OSx中。 我的代码:

class BuildRecordEditorDialog(QDialog, Ui_brePartEditDialog):
    def __init__(self):
        QDialog.__init__((self))
        self.setupUi(self)
        self.breDueDateEditor.setDisplayFormat('yyyy-MM-dd')
        self.brePickDateEditor.setDisplayFormat('yyyy-MM-dd')

# In another Module

        buildRecordEditDialog = BuildRecordEditorDialog()  # Create an edit dialog

        brUi = buildRecordEditDialog
        brUi.setupUi(buildRecordEditDialog)
        brUi.breDeleteLabel.hide()    # This is not a delete so hide the delete message
        brUi.brePartNoEditor.setText(selectedPart[1].text())  # Pre-load defaults from selected data
        brUi.breDescriptionEditor.setText(selectedPart[2].text())
        brUi.breQuantityEditor.setText(selectedPart[3].text())
        brUi.breDueDateEditor.setDate(QtCore.QDate.fromString(selectedPart[4].text(), "yyyy-MM-dd"))
        brUi.brePickDateEditor.setDate(QtCore.QDate.fromString(selectedPart[5].text(), "yyyy-MM-dd"))

我正在使用pyqt4,Python 3.5.4,Ubuntu Linux

我已将时间区域设置更改为:LC_TIME =" en_CA.UTF-8"但它没有帮助。

作为旁注,brUi.breDeleteLabel.hide()设置也不受尊重。

1 个答案:

答案 0 :(得分:0)

没有答案,所以我做了一个解决方案。我将对话框返回的日期从错误格式转换为我想要的日期,然后进行处理。用户看到了不同的格式,但是使用日期选择器输入数据,所以它将完成。