Qlabel中的setlabel会在pyqt中分配一个变量吗?
我仍然开始使用 PyQt 和 QtDesigner 使用 eric4 (并且仍在整体研究 python)。
不管怎样,正如我使用 QtDesigner 在 GUI 中设计的那样,我刚刚制作了一个 Qlabel 作为占位符,旨在使用可以访问我正在构建的 SQLite 数据库的最新 ID 进行更新。我希望它 setlabel 更改为 ID 主键中可用的下一个插槽,但老实说我不知道如何做。
我尝试更改 UI 编译形式,因为我注意到这一行:
self.ID_Number.setText(QtGui.QApplication.translate("Dialog","IDLabel", None, QtGui.QApplication.UnicodeUTF8))
设置了与 SQLite 通信的假定 ID_Number 的标签。但是当我将“IDLabel”更改为变量时,我总是遇到编译错误。我已经检查过它应该是一个常量,但它有可能是一个变量吗?或者我在 QtDesigner 中使用 QLabel 是错误的,我应该使用其他东西?
非常感谢任何帮助我解决我试图打破的墙的问题深深鞠躬
I'm still starting out with PyQt with QtDesigner using eric4 (and still studying python as a whole).
Anyway, as I've designed in a GUI using QtDesigner I've just made a Qlabel as a placeholder which is intended to update with the latest ID that has access to a SQLite database which I'm building. I want it to setlabel to change to the next slot available in ID primary key but I honestly don't know how.
I've tried to change the UI compiled form as I noticed that it is this line:
self.ID_Number.setText(QtGui.QApplication.translate("Dialog","IDLabel", None, QtGui.QApplication.UnicodeUTF8))
that sets the label of the supposed ID_Number which would communicate with the SQLite. But I always get a compiling error when I changed "IDLabel" to a variable. I've checked that it is supposed to be a constant but would it be possible that it can be a variable instead? Or am I doing wrong to use a QLabel in QtDesigner and I should use something else?
Any help in solving the wall I'm trying break is very much appreciated bows deeply
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
translate
函数调用用于多语言支持。在这种情况下,您可以将其删除并将代码简化为以下内容。The
translate
function call is used for multi-language support. You can remove it in this case and simplify the code to the following.