Results 1 to 3 of 3

Thread: subclassing or redrawing a lineEdit

  1. #1
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default 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

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: subclassing or redrawing a lineEdit

    (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.

  3. #3
    Join Date
    Feb 2006
    Posts
    26
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt3
    Platforms
    MacOS X Windows

    Default 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

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.