Can i read value from QLabel

混江龙づ霸主 提交于 2020-01-30 11:22:48

问题


I now how to set value(number) but can i read that label in some variable. if can't read, in which similar widgets can i put value and read it. Any help would be halpful or someone has an other idea. Maybe like LCD number, spin box


回答1:


Like this?

QString text = someLabel->text();



回答2:


Here is the documentation. QLabel.text()

EDIT:

QString text = theLabel.text();
//or with pointer
QString text = theLabel->text();



回答3:


have you tried :

QString s = YourQLabel->text();

This should work, I guess.




回答4:


// Thelepaty mode on

You need to use editor widgets, for example QLineEdit or QTextEdit. You may customize it via QSS to look like a QLabel.

P.S. try to improve your English. It is hard to understand, what you are asking.

// Thelepaty mode off


来源:https://stackoverflow.com/questions/59912392/how-do-you-get-the-current-value-of-a-qtlabel-in-python-pyqt5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!