Home > other >  QT problem: in the label drawing, so many points in total, you greatly, want to for a long time, hel
QT problem: in the label drawing, so many points in total, you greatly, want to for a long time, hel

Time:10-02

My goal is to create a window, the window to add the Label, the Label in picture real-time graph (eventually here AD card to collect voltage value, draw the graph), now just simple graph, the Label can be arbitrarily move position, the graph is also relatively move,

Use wizard defines a MainWindow class, then the new drawLabel class, drawLabel. CPP, inheritance in QLabel
Problem is 1, the window shows, not shown in Qlabel,
Code for drawing curve:
DrawLabel: : drawLabel (QWidget * parent) : QLabel (parent)
{
for(int i=0; iBuffer [I]=(int) (sin (100) (I * PI)/* 100);
QTimer * timer=new QTimer ();
QObject: : connect (timer, SIGNAL (timeout ()), and this, SLOT (flushBuff ()));
The timer - & gt; Start (100);
}
Void drawLabel: : flushBuff ()
{
Int TMP=buffer [0];
for(int i=0; i{
If (I==DATA_X - 1)
{
Buffer] [DATA_X - 1=TMP;
break;
}
Buffer [I]=buffer [I + 1);
}
The update ();
}
Void drawLabel: : paintEvent (QPaintEvent *)
{
QPainter painter (this);
The QPoint beginPoint;
QPoint endPoint.
Painter. SetPen (Qt: : red);
for(int i=0; i{
QDebug () & lt; & lt;" X="& lt; QWidget: : setSizePolicy (QSizePolicy: : Maximum, QSizePolicy: : Maximum);
DrawLabel * label=new drawLabel;
QMainWindow: : setCentralWidget (label);
}

MainWindow: : ~ MainWindow ()
{
Delete the UI;
}

Problem is to draw the graph has been on the window, not on a drawLabel, how can I draw on drawLabel ah, where I don't know what is problem, all 3 days, and thank you greatly!!!!! There is a problem: how to change the position of the drawLabel in your code, and so many points in total,

CodePudding user response:

QT don't understand,,,, don't look for me,

CodePudding user response:

reference 1st floor accessysq response:
QT do not understand,,,, don't look for me.


, have not used QT,

CodePudding user response:

You want to draw on the label, you must use the label corresponding drawing class function,
But look from LZ provide code, only defines the label, but didn't use it,

CodePudding user response:

Your artist should be specified the parent class, ha ha problem for a long time
QPainter painter (your label);