subclassing or redrawing a lineEdit
Hello,
I have a QLineEdit that I subclassed to add a lot of specific functionality for my app. To deal with alignment and style issues on my app, I need to have the active portion of the LineEdit occupy only a subset of the widget size, while still retaining all the properties and functionality of the new LineEdit.
Let me clarify: For a normal QLineEdit, the active portion (where you type) is the whole area of the widget. I need the right 1/4" to match the background. I know I could make a new widget and add a spacer to the right. Two problems with that are: (1) Even fixed-size spacers do not seem to hold their sizes, but will still expand and contract depending on their mood, regardless of size hints and size policy. (2) I need to access all the functionality of the widget directly -- properties and functions.
My thought was that if I use a subclass of QLineEdit and somehow only draw the lineEdit on the left leaving the right 1/4" free, that would do it. The paintEvent of my current QlineEdit calls "QLineEdit:: paintEvent(Event)" which will draw over the entire widget. How would I get QlineEdit to draw only on the part I want it to? The other problem is, how do I make the background match of the unpainted/unutilized portion.
Can anyone offer suggestions as to what would work here?
thank you,
Jay
Re: subclassing or redrawing a lineEdit
Quote:
(1) Even fixed-size spacers do not seem to hold their sizes, but will still expand and contract depending on their mood, regardless of size hints and size policy. (2) I need to access all the functionality of the widget directly -- properties and functions.
About poit 1,I am not sure that a spacer SHOULD be able to be with constant size, since its agaist its purpose, but I am not sure about this.
I prety sure this can be acheaved with a spacer, but sometime you need to play around with the layout to get it right.
You could also use some other widget, maybe an empty qlabel as a spacer.
Or you can calculate your desired QLineEdit geometry and adjust programaticaly on its parent.
Re: subclassing or redrawing a lineEdit
I need to point out that QlineEdit inherits QFrame so I used the setFrameRect() function to change the editable area of the edit. however, I still have the portion that is unpainted that needs to match the background, and that's the problem.
Thanks!
Jay