Qt Python Calendar:选定日期直接访问
我的日历运行良好。
这是显示完整日期的函数: 这里是
def selectDate(self,date):
self.fullDate = str(date.day()) + " / " + str(date.month()) + " / " + str(date.year())
print "full date: %s" % self.fullDate
带有日历的代码:
def TabCalendar(self):
self.calendar = QtGui.QCalendarWidget(self.tab)
self.calendar.setGeometry(QtCore.QRect(self.x1, self.y1, self.x2, self.y2))
QtCore.QObject.connect(self.calendar, QtCore.SIGNAL("selectionChanged()"), self.selectDate)
QtCore.QObject.connect(self.calendar, QtCore.SIGNAL("clicked(QDate)"), self.selectDate)
为了直接访问选定的日期,我根据连接事件调用函数 selectDate,然后使用“日期”来获取精确的日期。日等等——效果很好。
唯一让我恼火的尴尬是它给出了以下警告..
TypeError: turbSchedule_selectDate() takes exactly 2 arguments (1 given)
有什么建议来停止这个 TypeError 警告吗?
高度赞赏所有意见和建议。
I have calendar that is working fine.
Here is the function that display the full date:
def selectDate(self,date):
self.fullDate = str(date.day()) + " / " + str(date.month()) + " / " + str(date.year())
print "full date: %s" % self.fullDate
And here the code with the calendar:
def TabCalendar(self):
self.calendar = QtGui.QCalendarWidget(self.tab)
self.calendar.setGeometry(QtCore.QRect(self.x1, self.y1, self.x2, self.y2))
QtCore.QObject.connect(self.calendar, QtCore.SIGNAL("selectionChanged()"), self.selectDate)
QtCore.QObject.connect(self.calendar, QtCore.SIGNAL("clicked(QDate)"), self.selectDate)
To have direct access to selected day, I am calling the function selectDate based on connect event, and then using the 'date' to obtain the precise date.day and so on -- which is working fine.
The only awkward thing that is annoying me is that it gives the following warning..
TypeError: turbSchedule_selectDate() takes exactly 2 arguments (1 given)
Any suggestion to stop this TypeError warning?
All comments and suggestions are highly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我猜想 selectdate 信号调用的槽不应该有任何参数。您可以通过相应的日历方法访问selectedDate。
请参阅 C++ 文档: http://doc.trolltech.com/4.3/widgets-calendarwidget .html
所以你的代码应该是这样的:
I guess that the slot called by the selectdate signal shouldn't have any argument. You can access the selectedDate by the corresponding calendar method.
See the c++ docs: http://doc.trolltech.com/4.3/widgets-calendarwidget.html
So your code should be something like: