[Qt-interest] line edit focus problem
Yuvaraj R
yuvaraj at ongobiz.com
Thu Jul 16 14:54:32 CEST 2009
Hi All
I override the MainWindow event filte function..
By
bool Con_Main ::eventFilter(QObject *o,QEvent *e)
{
if(e->type == QEvent::KeyPress)
{
e->ignore}
}
. it is giving conflicting errors.errors..
what mistake i have done here..
please suggest me
Thanks
Yuvaraj R
On Thu, Jul 16, 2009 at 5:41 PM, Tony Rietwyk <tony.rietwyk at rightsoft.com.au
> wrote:
>
>
> -----Original Message-----
> Hi All
>
> 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")
>
> 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");
> }
> }
>
> Please help , what's wrong with me
>
>
> Thanks
>
> Yuvaraj R
>
>
> There is nothing wrong!
>
> You are listening to the events on the main window, and it only gets the
> key strokes when the edit doesn't have focus.
>
> I suggest to either:
>
> - use the same code, but subclass from QLineEdit,
> - or use
>
> ui.lineEdit->installEventFilter( this );
>
> and override the eventFilter method in MainWindow.
>
> I normally take the second option.
>
> Tony.
>
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090716/b2600784/attachment.html
More information about the Qt-interest-old
mailing list