Results 1 to 6 of 6

Thread: Drawing on a widget created via QDesigner

  1. #1
    Join Date
    Aug 2008
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Drawing on a widget created via QDesigner

    I know how to draw a picture on a QMainWindow via QPainter:

    QPainter painter(this).

    But, after creating a QFrame (named frame_1) via QDesigner, how to implement the paintEvent in order to make it working with my QFrame ?

    In short, I would like to point to my QFrame, not the default (this) QMainWindow.

    I have not seen any code from Google or from this forum, since QDesigner is not very used.

    By advance, thank you for any help.http://www.qtcentre.org/forum/images/icons/icon3.gif

    Jean (a novice, of course).

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drawing on a widget created via QDesigner

    you can install event filter for your QFrame object and then handle its QPaintEvent.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Drawing on a widget created via QDesigner

    Create a QFrame subclass and promote it in designer.
    J-P Nurmi

  4. #4
    Join Date
    Aug 2008
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drawing on a widget created via QDesigner

    Thanks for these 2 answers.

    My knowledge of C++ processes is still poor (I come from Delphi), but I presume that subclassing would be faster than using an eventFilter. Am I right ?

    In fact, I tryed both them, without anay results.
    I red the <promote> URL pointed by JPN, but I understood that promoting is only when you want to customize a widget. The widget is created within QDesigner (an .ui file) but I don't know of to double inherit a QFram object and an object still created with QDesigner.

    Could be more explicit ?
    Thank you by advance.
    Jean.

  5. #5
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Drawing on a widget created via QDesigner

    read this thread http://www.qtcentre.org/forum/f-newb...light=QPainter, maybe it will help you.
    Qt Assistant -- rocks!
    please, use tags [CODE] & [/CODE].

  6. The following user says thank you to spirit for this useful post:

    jean (15th January 2009)

  7. #6
    Join Date
    Aug 2008
    Posts
    10
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Drawing on a widget created via QDesigner

    Thank you !
    Now, I have a little bit understand the process. And it works.
    Jean.

Similar Threads

  1. QDockWidget inside another widget in the center?
    By Antebios in forum Qt Programming
    Replies: 1
    Last Post: 16th February 2010, 07:06
  2. Drawing a widget in QItemDelegate's paint method
    By darkadept in forum Qt Programming
    Replies: 17
    Last Post: 11th August 2009, 05:15
  3. Replies: 6
    Last Post: 3rd September 2008, 14:27
  4. Replies: 1
    Last Post: 2nd August 2008, 15:46
  5. Replies: 2
    Last Post: 8th February 2008, 14:31

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.