DrawTest for QT GUI Application(QT波形繪製執行個體)

來源:互聯網
上載者:User

根據提供的數組和設定的顯示範圍進行波形的顯示,改變視窗大小,波形和刻度標記都會相應改變。

原始碼下載 :http://download.csdn.net/source/1963001

關鍵技術點:

1、從QGraphicsView 類派生自訂的類:“GraphicsView”,重寫 resizeEvent(QResizeEvent *) 方法。

class GraphicsView : public QGraphicsView<br />{<br />public:<br />GraphicsView (QWidget * parent = 0);<br />protected:<br />void resizeEvent(QResizeEvent *event) {<br />if (scene()){<br />scene()->setSceneRect(QRect(QPoint(0, 0), event->size()));<br />}<br />QGraphicsView::resizeEvent(event);<br />}<br />};

2、將根據*.ui檔案產生的ui_*.h檔案中的

QGraphicsView *graphicsView ;

... ...

graphicsView = new QGraphicsView(gridLayoutWidget );

改成 :

GraphicsView *graphicsView ;

... ...

graphicsView = new GraphicsView(gridLayoutWidget );

當然還要記得:

#include "GraphicsView.h"

3、要添加QGridLayout *gridLayout ;並將它的parent 指定為 表單的QWidget,預設是自動產生的gridLayoutWidget

gridLayout = new QGridLayout(DrawTestClass );

4、重寫 視窗類別的resizeEvent(QResizeEvent *)

 

void DrawTest::resizeEvent(QResizeEvent *event){<br /> QWidget::resizeEvent(event);<br /> drawClicked();//繪製函數<br />}

 

 

5、原始碼下載:http://download.csdn.net/source/1963001

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.