Results 1 to 7 of 7

Thread: QPainter Event help

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Jul 2017
    Posts
    13
    Qt products
    Qt4
    Platforms
    Unix/X11
    Thanks
    3

    Question Re: QPainter Event help

    [ATTACH=CONFIG]12572
    Hi Wysota

    Thanks For the reply. I have done graph plotting using qtpaint event. I want to Freeze Graph on my button Click. I googled this info but no luck. is there any method to achieve Grpah freeze method using Qt paintevent
    I don't have a Idea To freeze Graph like a screen shot.

    [

    Here is my code :

    This paint event triggered by timer


    void GraphArea_Single_ECG_1::paintEvent(QPaintEvent *Mypaint)
    {
    Q_UNUSED(Mypaint);
    QPainter Single_ECG_1_Painter(this);

    if(Screen_Empty_Flag == false)
    {
    QPen Pen_Single_ECG_1(Qt::green);
    Pen_Single_ECG_1.setWidth(2);
    Single_ECG_1_Painter.setPen(Pen_Single_ECG_1);
    Single_ECG_1_Painter.setRenderHint(QPainter::Antia liasing,true);

    Single_ECG_1_Painter.drawLine(X_Position, (127 - Single_ECG_1_Previous_Graph_data) +075, X_Position+1, (127 - Single_ECG_1_Current_Graph_data) +075);

    QPen gap (Qt::black);
    Single_ECG_1_Painter.setPen(gap);
    Single_ECG_1_Painter.drawRect(X_Position+ 5, 0, 1, 1000);
    Single_ECG_1_Painter.drawRect(X_Position+10, 0, 1, 1000);
    Single_ECG_1_Painter.drawRect(X_Position+15, 0, 1, 1000);

    Single_ECG_1_Previous_Graph_data = Single_ECG_1_Current_Graph_data;
    }

    else
    {
    QBrush brush(Qt::black, Qt::SolidPattern);
    Single_ECG_1_Painter.fillRect(0, 0, 2000, 1000, brush);
    X_Position = 0;
    Screen_Empty_Flag = false;
    }
    }


    /****Qt paint Event Trigger Function ******/

    void GraphArea_Single_ECG_1::Timer_Single_ECG_1_Timeout ()
    {
    if(!Array_ECG_1_Data.isEmpty())
    {
    Single_ECG_1_Current_Graph_data = Array_ECG_1_Data.takeFirst() + 100;
    }

    X_Position++;
    if(X_Position > Graph_Width)
    X_Position=0;

    this->update();
    }

    /**********Timer Inialization**********/

    void GraphArea_Single_ECG_1::Timer_Initialization_Singl e_ECG_1()
    {
    Timer_Single_ECG_1 = new QTimer(this);
    Timer_Single_ECG_1->setInterval(6);
    connect(Timer_Single_ECG_1, SIGNAL(timeout()), this, SLOT(Timer_Single_ECG_1_Timeout()));

    }]
    Attached Images Attached Images

Similar Threads

  1. Replies: 2
    Last Post: 26th December 2012, 01:03
  2. QPainter immediate drawing outside paint event
    By sfcheng77 in forum Qt Programming
    Replies: 1
    Last Post: 23rd February 2011, 06:39
  3. Replies: 1
    Last Post: 5th October 2010, 17:08
  4. Replies: 5
    Last Post: 7th September 2009, 20:57
  5. Replies: 3
    Last Post: 30th April 2006, 19:22

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
  •  
Qt is a trademark of The Qt Company.