Question

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

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top