0

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

Mcolorz
  • 145
  • 1
  • 5
  • 20

1 Answers1

2

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.

kenrogers
  • 1,350
  • 6
  • 17
  • ya i have QDialogButtonBox in it having two buttons.one is Ok and other isCancel.Ok is connected to accept and cancel to reject.But i want those buttons too in my layout then how can i do this? – Mcolorz Jul 12 '12 at 04:53
  • i checked right now that even with the reject slot connected to both Ok and Cancel,the same thing is happening. – Mcolorz Jul 12 '12 at 04:54
  • nd ya on removing those buttons my problem is solved but i want those buttons on my layout as i have been asked to do – Mcolorz Jul 12 '12 at 04:58
  • Perhaps you could connect to the lineedit's textChanged signal instead of using returnPressed? – kenrogers Jul 12 '12 at 12:14