koenig
28th January 2010, 13:09
Hi,
Firslty I'm very new to QT (as well as GUI programming) but quickly falling in love with it :)
Having said that however, I have hit my first wall which is probably a lack of understanding something. I am useing eclipse with QT integration (V4.6).
As a test I have crated a form using the designer with a simple text entry widget and a button
I then created a slot for the buttons clicked signal
In the routine processing the signal I read the text from the entry and set the text for the button label to reflect that.
Copiled and ran fine. I can enter text in the entry box and when I click on the button it's label changes to what I entered.
However the text in the entry box does not get cleared so I issued the clear method on it following the set text method on the button.
Now when I click on th button the text in the entry box gets cleared which is fine, but so does the label of the button which I don't get.
Below is the implementation of the slot function:
void qt_test::on_enterButton_clicked()
{
QString buttonName = ui.lineInput->displayText();
ui.enterButton->setText(buttonName);
ui.lineInput->clear();
}
ui.lineIput is of class QLineEdit
ui.enterButton is of class QPushButton
inially the push button has the text "Push" on it then when I push it it get cleared irrespective of what has been entered in the lineInput
The itneresting thing is that if I do this:
void qt_test::on_enterButton_clicked()
{
QString buttonName = ui.lineInput->displayText();
buttonName += "ABC";
ui.enterButton->setText(buttonName);
ui.lineInput->clear();
}
The push button text gets set to "ABC" again irrespective of what is entered in lineInput.
Any one able to tell me why this is so?
Thanks!
Firslty I'm very new to QT (as well as GUI programming) but quickly falling in love with it :)
Having said that however, I have hit my first wall which is probably a lack of understanding something. I am useing eclipse with QT integration (V4.6).
As a test I have crated a form using the designer with a simple text entry widget and a button
I then created a slot for the buttons clicked signal
In the routine processing the signal I read the text from the entry and set the text for the button label to reflect that.
Copiled and ran fine. I can enter text in the entry box and when I click on the button it's label changes to what I entered.
However the text in the entry box does not get cleared so I issued the clear method on it following the set text method on the button.
Now when I click on th button the text in the entry box gets cleared which is fine, but so does the label of the button which I don't get.
Below is the implementation of the slot function:
void qt_test::on_enterButton_clicked()
{
QString buttonName = ui.lineInput->displayText();
ui.enterButton->setText(buttonName);
ui.lineInput->clear();
}
ui.lineIput is of class QLineEdit
ui.enterButton is of class QPushButton
inially the push button has the text "Push" on it then when I push it it get cleared irrespective of what has been entered in the lineInput
The itneresting thing is that if I do this:
void qt_test::on_enterButton_clicked()
{
QString buttonName = ui.lineInput->displayText();
buttonName += "ABC";
ui.enterButton->setText(buttonName);
ui.lineInput->clear();
}
The push button text gets set to "ABC" again irrespective of what is entered in lineInput.
Any one able to tell me why this is so?
Thanks!