I have set the line edit text as default by "Dial number"
When i pressing the keys in keyboard ,then i am clearing the lineedit text and inserting the pressed key value in line edit..
if i set lineEdit in setfocusby default..
that time any key events is not uptating ..
if diable the forucs for line edit.. key event are updating..
Sample code..
ui.lineEdit.setText("Dial Number")
{
switch(e->key)
{
case Key_0 :
if(ui.lineEdit.Text == "Dial Number")
{
ui.lineEdit.clear }
ui.lineEdit.insert("0");
break;
case Key_1 :
if(ui.lineEdit.Text == "Dial Number")
{
ui.lineEdit.clear }
ui.lineEdit.insert("1");
}
}
ui.lineEdit.setText("Dial Number")
void MainWindow::keyPressEvent(QKeyEvent *e)
{
switch(e->key)
{
case Key_0 :
if(ui.lineEdit.Text == "Dial Number")
{
ui.lineEdit.clear }
ui.lineEdit.insert("0");
break;
case Key_1 :
if(ui.lineEdit.Text == "Dial Number")
{
ui.lineEdit.clear }
ui.lineEdit.insert("1");
}
}
To copy to clipboard, switch view to plain text mode
Then i overrided the QLineEdit KeyPressEvent.
{
Q_OBJECT
public:
};
class Con_Main : public QLineEdit
{
Q_OBJECT
public:
Con_Main(QWidget *parent = 0);
void keyPressEvent(QKeyEvent *e);
};
To copy to clipboard, switch view to plain text mode
{
}
{
// e->ignore();
}
Con_Main::Con_Main(QWidget *parent = 0):QLineEdit(parent)
{
}
void Con_Main::keyPressEvent(QKeyEvent *e)
{
// e->ignore();
QMessageBox::information(0,"",QString("Con_main"));
}
To copy to clipboard, switch view to plain text mode
I have doubt at KeyPressEvent to over ride this method, have to ignore the event .what i have to do here..
And it is giving the
error: default argument given for parameter 1 of `Con_Main::Con_Main(QWidget*)'
error: after previous specification in `Con_Main::Con_Main(QWidget*)'
Please help me
Thanks
Yuaraj R
Bookmarks