Results 1 to 6 of 6

Thread: Overiding PaintEvent for QLabel

  1. #1
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Overiding PaintEvent for QLabel

    Hi

    I have designed a gui in designer and I need to re-implement the paint event for a label. What is the best way of doing this?

    Regards

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Overiding PaintEvent for QLabel

    Subclass QLabel in lets say MyLabel. Then use MyLabel "normaly" in the designer by promoting the widget. (right click -> promote: ther insert mylabel.h etc.)

    If you want full preview you have to code a plugin for the designer.

  3. #3
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Overiding PaintEvent for QLabel

    Thanks

    Does I have to declare the subclass MyLabel in a separate header file? I'd rather not do that. Is there an alternative method?

    Thanks

  4. #4
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Overiding PaintEvent for QLabel

    Quote Originally Posted by dbrmik View Post
    Does I have to declare the subclass MyLabel in a separate header file? I'd rather not do that.
    Where do you wish to declare it?

  5. #5
    Join Date
    Oct 2008
    Posts
    74
    Thanks
    5
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Overiding PaintEvent for QLabel

    Hi

    I'd like to declare it in the subclass of my gui. But that does not seem to work.

    Thanks

  6. #6
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: Overiding PaintEvent for QLabel

    You can declare it everywhere you wont, but as for good coding style: each class has its own *.h and *.cpp.

Similar Threads

  1. Possible to use a widget in another widget's paintEvent?
    By robot_love in forum Qt Programming
    Replies: 2
    Last Post: 9th September 2008, 06:18
  2. painting a widget outside a paintEvent
    By jayw710 in forum Qt Programming
    Replies: 1
    Last Post: 26th June 2007, 00:18
  3. Replies: 3
    Last Post: 27th November 2006, 10:56

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.