Results 1 to 4 of 4

Thread: Draw button(similer to QPushButton) using the QPainter.

  1. #1
    Join Date
    Jul 2010
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Post Draw button(similer to QPushButton) using the QPainter.

    Hi Friends,

    I am implementing some graphics related application(like a radar view). In the view I have to draw the real time data on the screen. There are some attribute of that data (like status as progress bar, tool tip, image, mouse event).

    Hence I am:

    - First implementing the basic screen using the paint class. In the paint I am using "setViewport" and "setWindow" for re-size consideration.
    - Then I am using the custom button (QPushButton) for the attributes.

    First I want to ask, "is this the correct approach" or there is any thing in the paint class that provide me click functionality. If I want to go with the paint class then it will be easy to represent the live data, but due to live data attribute I can not go for it.

    Please suggest me for the missing functionality or better approach.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Draw button(similer to QPushButton) using the QPainter.

    I would probably do this another way. I would use a QGraphicsView, create some custom items for the radar and then use a qgraphicsproxywidget for the pushbutton or checkboxes etc...

  3. The following user says thank you to tbscope for this useful post:

    pastispast (24th July 2010)

  4. #3
    Join Date
    Jul 2010
    Posts
    38
    Thanks
    8
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Re: Draw button(similer to QPushButton) using the QPainter.

    Quote Originally Posted by tbscope View Post
    I would probably do this another way. I would use a QGraphicsView, create some custom items for the radar and then use a qgraphicsproxywidget for the pushbutton or checkboxes etc...
    Hi "tbscope"...Thanks to suggest the above approach. I feel this is the better approach to do the above condition. Now I am using this approach.

    But now after putting the controls over the QGraphicsView, I am getting the problem while resizing:

    - I am using resizing event for resizing the QGraphicsView:
    QGraphicsView::resizeEvent(event);
    fitInView(scene->sceneRect(), Qt::KeepAspectRatio);

    - But during the resize controls are not synchronize with the QGraphicsView.

    What can be the cause of this?

    I have one more doubt that can I use QPainter drawing in "QGraphicsView".

    Once again thanks for the reply.
    Last edited by pastispast; 23rd July 2010 at 19:19. Reason: Some points are not added...

  5. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Draw button(similer to QPushButton) using the QPainter.

    Quote Originally Posted by pastispast View Post
    - I am using resizing event for resizing the QGraphicsView:
    QGraphicsView::resizeEvent(event);
    fitInView(scene->sceneRect(), Qt::KeepAspectRatio);

    - But during the resize controls are not synchronize with the QGraphicsView.

    What can be the cause of this?
    What do you mean with synchronize? Do you mean that all the objects jump around?

    I have one more doubt that can I use QPainter drawing in "QGraphicsView".
    Sure, but it's pointless as the view is a container for items that are drawn on top of it.
    The correct way to do this is create a custom QGraphicsItem and implement the paint function. See the QGraphicsItem documentation.

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

    pastispast (24th July 2010)

Similar Threads

  1. Draw line on image using QPainter
    By Qt Coder in forum Qt Programming
    Replies: 29
    Last Post: 11th August 2015, 12:09
  2. QPainter performance for zooming and draw...
    By Programm3r in forum Qt Programming
    Replies: 1
    Last Post: 15th April 2010, 10:29
  3. QPainter::drawText, draw big text
    By franco.amato in forum Newbie
    Replies: 3
    Last Post: 18th March 2010, 08:32
  4. QPainter doesn't seem to draw QImage
    By Denarius in forum Qt Programming
    Replies: 7
    Last Post: 3rd March 2009, 14:12
  5. QPainter draw rounded arrow
    By xgoan in forum Qt Programming
    Replies: 1
    Last Post: 9th November 2006, 12:32

Tags for this Thread

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.