[Qt-interest] Preventing highlighting of QLineEdit

Ulf-Alexander v. Ceumern-Lindenstjerna ceumern at vrmagic.com
Fri Jan 15 10:27:41 CET 2010


If I read this right you use QLabels to paint some form of decoration around you QLineEdit? Why not use a style sheet to customize your QLineEdit altogether?

e.g.:

QLineEdit {
border-image: url(:/le.png) 12;
border: 10px transparent;
}
/* focus indicator for line edits */
QLineEdit::focus {
border-image: url(:/le_focus.png) 12;
}

This way you can control the look of your line edit in both (focus/non focus) states.

Cheers, Ulf

> -----Original Message-----
> From: qt-interest-bounces at trolltech.com [mailto:qt-interest-
> bounces at trolltech.com] On Behalf Of KC Jones
> Sent: Friday, January 15, 2010 2:59 AM
> To: Paul England
> Cc: Qt-interest
> Subject: Re: [Qt-interest] Preventing highlighting of QLineEdit
> 
> Thanks for the suggestions, but no luck.
> 
> Setting Qt::NoFocus makes the widget inaccessible and inactive, which
> is not what I want.
> 
> setReadOnly(false) seems to have no effect.
> 
> A little more context: I am implementing a toolbar search widget that
> surrounds the QLineEdit with QLabels that "paint" a oval lozenge
> around the edit box.  I'm not convinced this approach will work, but
> I'm trying to avoid having to write my own paint() method.  So taking
> this composite widget approach, the highlighting "flair" that Qt draws
> when the QLineEdit has focus is not wanted.
> 
> I don't care if I accomplish this with style sheets or by other means.
>  It just seems like this is something that should be handled via style
> sheets.
> 
> On Thu, Jan 14, 2010 at 4:24 PM, Paul England <pengland at cmt-asia.com>
> wrote:
> > Are you dead set on using a style?
> > I'm assuming that setFocusPolicy( Qt::NoFocus) would get the job
> done.
> > I use it on QTableWidget all the time.  I'm not sure if adding a
> style
> > will over write this or not though.  The other thing is if it's
> editable
> > or not.
> > setReadOnly( false ) I'm pretty sure will eliminate the problem
> altogether,
> > but introduce a huge one if it's not read only. :)
> >
> > KC Jones wrote:
> >> I have a QLineEdit widget where I do not want to see any frame or
> >> frame highlighting.  I know how to eliminate the frame, either by
> >> calling the setFrame(false) or via style sheet.  But I have not had
> >> any luck getting rid of the edit highlight.  I've played with the
> >> :edit-focus pseudo state:
> >>
> >> QLineEdit:focus { border-style: none; }
> >>
> >> but so far nothing is working.  I know the ":focus" is the state I
> >> want since I can set other properties and see them applied
> correctly.
> >> But the fuzzy blue (Mac) highlighting is still drawn.  Any
> >> suggestions?
> >> _______________________________________________
> >> Qt-interest mailing list
> >> Qt-interest at trolltech.com
> >> http://lists.trolltech.com/mailman/listinfo/qt-interest
> >>
> >
> 
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest




More information about the Qt-interest-old mailing list