Can i read value from QLabel

2020-05-11 02:17发布

问题:

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


标签: c++ qt label