Results 1 to 4 of 4

Thread: Paint events

  1. #1
    Join Date
    Mar 2010
    Posts
    107
    Thanks
    22
    Qt products
    Qt4
    Platforms
    Windows

    Default Paint events

    Hi all
    I have a simple application consising of a main window that contains some other widgets. I have created this using visual studio and QDesigner.
    The question is is it possible to catch the paintEvent events for the individual widgets on the form ?
    For example can I have a handler for a given widget on the form - if so how is this done();

    Thanks

    Graham

  2. #2
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Paint events

    Have a look at: http://doc.trolltech.com/4.6/qobject...allEventFilter

    But what do you want to achieve? There might be a better way of doing it!

    Johannes

  3. #3
    Join Date
    Mar 2010
    Posts
    107
    Thanks
    22
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Paint events

    Hello
    Thanks for the qick reply
    I am just starting out with Qt and so am looking at how things are done.
    What I wanted to do was to change the color of a push button when it is pressed and then return it to the default when released.
    Is there a better way to do this?

    Thanks

  4. #4
    Join Date
    Feb 2007
    Location
    Karlsruhe, Germany
    Posts
    469
    Thanks
    17
    Thanked 90 Times in 88 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Paint events

    To change the appearance of a class of widgets you should subclass the class and implement the behaviour changes there.
    You create a new kind of buttons.. You can then promote your widgets to your derived class in Designer.

    To just change the color of a button in different circumstances, it might be enough to change the palette of the buttons - or that of your mainform as they inherit it.
    But I'm not sure if your desired behaviour can be achieved with a changed palette. Never tried that :->

    HIH

    Johannes

Similar Threads

  1. paint events
    By freekill in forum Newbie
    Replies: 3
    Last Post: 18th February 2010, 06:29
  2. Problem with QGLWidget paint events in Qt 4.6
    By Wali in forum Qt Programming
    Replies: 1
    Last Post: 11th December 2009, 09:41
  3. Replies: 0
    Last Post: 3rd March 2009, 15:38
  4. How to distinguish paint events
    By naruto_9w in forum Qt Programming
    Replies: 6
    Last Post: 18th January 2009, 11:27
  5. paint
    By xyzt in forum Qt Programming
    Replies: 3
    Last Post: 22nd March 2008, 18:22

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.