[PyKDE] QLineEdit setCursorPosition & cursor blinking problems
Ulrich Berning
ulrich.berning at desys.de
Thu Jul 7 12:32:05 BST 2005
Danu Kusmana schrieb:
>Hi!
>I have sent email about this problems before but no one reply it.
>
>I reimplement the focusInEvent() with:
>
>class classEntry(QLineEdit):
> def focusInEvent(self, event):
> self.setPaletteBackgroundColor(QColor(188,255,203))
> self.setCursorPosition(0)
>
> def focusOutEvent(self, event):
> self.setPaletteBackgroundColor(QColor("white"))
>
>and make an object:
>
>self.EntryDiastolik = classEntry(self.centralWidget(),
> "EntryDiastolik")
>self.EntryDiastolik.setSizePolicy(QSizePolicy(0,0,0,0,
> self.EntryDiastolik.sizePolicy().hasHeightForWidth()))
>self.EntryDiastolik.setMaxLength(3)
>self.EntryDiastolik.setValidator(QIntValidator(self.EntryDiastolik))
>
>What happen is that:
>1. The cursor is not blinking at the focused line edit only the
>background color changes.
>2. After I entered some values to the line edit the cursor position 0 is
>place after the entered values, not from the begining of the line edit.
>
>Can anyone help me with this?
>
>
If you reimplement methods of a base class, you normally call the method
of the base class before or after your own functionality. Otherwise you
would have to reimplement the whole functionality of the base class method.
Calling QLineEdit.focusInEvent(self, event) in your focusInEvent()
method and QLinieEdit.focusOutEvent(self, event) in your focusOutEvent()
should help.
Note: If you call setCursorPosition(0), you loose the text selection and
there is no way to keep the text selected and have the cursor at the
beginning of the text.
Ulli
More information about the PyQt
mailing list