QWidget slots and focus
-
Hi,
I'm a beginner with Qt and therefore have some basic questions.I have made a very simple test program to demonstrate my issue.
If I click on the button "Set Text 1" the text "Test push button" is displayed in the lineEdit "Text1".
If I enter a text in "Text input" I copy this text into "Text Copy"
The behavior I don't understand is that when I enter a text in "Text input" and hit the enter key it fires also the pushButton slot and the text in "Text 1" is also displayed witout clicking on the button.
The related question is: Why if the focus is on Text input it remains also on the button?
Here is the code of the slots:
void MyDialog::on_setText1_clicked()
{
ui->lineEdit->setText("Test push button");
}void MyDialog::on_textInput_editingFinished()
{
QString m_text = ui->textInput->text();
ui->textCopy->setText(m_text);
}Thank you
-
Hi,
What version of Qt ?
On what OS ?
Can you show the whole code you are using ?
Maybe provide a minimal compilable example that shows the behaviour ? -
Hi and thank you for taking a look at my issue or my lack of knomledge about Qt.
I'm using Qt with Windows 10
I'm using
The complete test project can be downloaded from the link below
https://www.dropbox.com/s/pb9usnmp6jxb312/MainWindow1.zip?dl=0
Regards -
These are the information about Qt Creator.
What version of Qt are you using to build your project ?
-
It's defined in the Kit you are using to build your application.
-
@Bert59 said in QWidget slots and focus:
The behavior I don't understand is that when I enter a text in "Text input" and hit the enter key it fires also the pushButton slot
Hi,
Because your button is the default one of the dialog.
Very common issue, see Here