preesing enter on QLineEdit terminates the screen

i have a QLineEdit on my main screen define by QDialog.along with it i have a table which contains dynamic data displayed by QThread with 50 data in every 2 seconds.when i input any value in QLinrEdit and then press enter then the screen terminates.

 value = new QLineEdit(this);
        m_label = new QLabel(tr("&Enter Preference Value:"));
        m_label->setBuddy(value);
        m_preLayout->addWidget(m_label);
        m_preLayout->addWidget(value);
        m_preferenceGroup->setLayout(m_preLayout);
        connect(value, SIGNAL(returnPressed()), this, SLOT(preferentialData()));

void appWindow::preferentialData()
{
        valuee = (value->text()).toInt();
}

here i am taking the input from user and then converting that input into an integer which will be further used for some other purpose.Now after taking that input as per signal i press enter and as soon as after that the screen closes.

the value is converted to int and no errors are coming on compiling but why is the window closing? because if it closes then the thing that i will further do with that converted int will be like of no use as with the help of that int i will change some display on my table as i mentioned that i have a table too in that window.

thanks for any help in advance

Answers


I'm almost certain (can't be sure without seeing more code) that the dialog is taking the "Enter" keypress and calling its accept() method, which closes the dialog. If you made the dialog in Qt Creator and chose one of the dialog types that places a button box on the form for you, then this connection is wired up by default.

Check your dialog's signal/slot connections and make sure that the accept() slot isn't connected to a QPushButton or QDialogButtonBox signal.


Need Your Help

using sympy solver and numpy dot doesn't work

python numpy sympy

I'm trying to solve a long equation using sympy solve. This is a simplified version of the equation but the issue is the same.

Making a JFrame act like a dialog box

java swing jframe jbutton

I have a form for the user to fill out in a JFrame which then writes the collected data to a JTable in a different class.