how to make a widget that could input the text then the text became the widget
-
I just added the qedittext into my project.and i want to wrote a widget that the qedittext could input the text.and when the text was finished ,then the text part just inputed became the other widget(such as the qpushbutton else).so how to figure it out?it is too hard for me to get the whole part.
-
If you want to show one widget in the place of the other you can use
QStackedWidget
. So after the user has entered text into say, aQLineEdit
take the text, set it to aQPushButton
orQlabel
's text, and switch to that in theQStackedWidget
instead of theQLineEdit
.If you don't care about hiding the original
QLineEdit
then you don't need aQStackedWidget
.To create a new widget use
new
. You can place it wherever on an existing layout.All you really need is
pushButton->setText(lineEdit->text())
, so what is hard? -
I just added the qedittext into my project.and i want to wrote a widget that the qedittext could input the text.and when the text was finished ,then the text part just inputed became the other widget(such as the qpushbutton else).so how to figure it out?it is too hard for me to get the whole part.
So basically
QItemDelegate
behavior?!
When you click the widget you get lineEdit editor to write text and when you are done wirh writing, you switch to "display" mode and just show the text?! -
If you want to show one widget in the place of the other you can use
QStackedWidget
. So after the user has entered text into say, aQLineEdit
take the text, set it to aQPushButton
orQlabel
's text, and switch to that in theQStackedWidget
instead of theQLineEdit
.If you don't care about hiding the original
QLineEdit
then you don't need aQStackedWidget
.To create a new widget use
new
. You can place it wherever on an existing layout.All you really need is
pushButton->setText(lineEdit->text())
, so what is hard?@JonB
what I just mentioned looks like the pic above.when inputed the "w" part then the text became the qlabel or qpushbutton something. -
@JonB
what I just mentioned looks like the pic above.when inputed the "w" part then the text became the qlabel or qpushbutton something.@nicker-player This picture does not help to understand what you want to do. But my understanding is same as @JonB : you can use QStackedWidget...