|
现在马上就要结束了,竟然又出现这么诡异的问题,我的画图窗口最小化之后再打开,原来画的曲线竟然就不见了,5555555555
我的部分代码:
void tppaintForm::paintEvent(QPaintEvent *)
{
paint = new QPainter;
int x1, y1, x2, y2;
paint->begin(this);
//paint->setBrush(QBrush(QColor( 173, 210, 222 ), Dense7Pattern));
paint->setBrush(QBrush(QColor( 237, 254, 255 )));
paint->drawRect(60,20,370,320);
paint->drawLine ( 240, 20, 240, 340 );//xmiddleline
paint->drawLine ( 60, 70, 425, 70 );//11
paint->drawLine ( 60, 130, 425, 130 );//10.5
paint->drawLine ( 60, 200, 425, 200 );//10
paint->drawLine ( 60, 270, 425, 270 );//9.5
signal(SIGUSR1, throutput);
}
QPaintDevice::~QPaintDevice()
{
}
tppaintForm::tppaintForm()
{
resize( QSize(470, 400).expandedTo(minimumSizeHint()) );
setGeometry( /* middle */
(QApplication::desktop()->width()-width()) / 2,
(QApplication::desktop()->height()-height()) / 2 -12,
/* middle */
width(),
height());
setMaximumSize( QSize( 470, 400 ) );
setCaption( tr( "Throuput Plot" ) );
setPaletteBackgroundColor( QColor( 250, 250, 250 ) );
tpClosepushButton = new QPushButton( this, "tpClosepushButton" );
tpClosepushButton->setGeometry( QRect( 280, 375, 70, 20 ) );
tpClosepushButton->setPaletteBackgroundColor( QColor( 173, 210, 222 ) );
QFont tpClosepushButton_font( tpClosepushButton->font() );
tpClosepushButton_font.setFamily( "Utopia" );
tpClosepushButton_font.setPointSize( 11 );
tpClosepushButton_font.setBold( TRUE );
tpClosepushButton_font.setItalic( TRUE );
tpClosepushButton->setFont( tpClosepushButton_font );
tpClosepushButton->setText( tr( "Close" ) );
tpupdatepushButton = new QPushButton( this, "tpupdatepushButton" );
tpupdatepushButton->setGeometry( QRect( 140, 375, 70, 20 ) );
tpupdatepushButton->setPaletteBackgroundColor( QColor( 173, 210, 222 ) );
QFont tpupdatepushButton_font( tpupdatepushButton->font() );
tpupdatepushButton_font.setFamily( "Utopia" );
tpupdatepushButton_font.setPointSize( 11 );
tpupdatepushButton_font.setBold( TRUE );
tpupdatepushButton_font.setItalic( TRUE );
tpupdatepushButton->setFont( tpupdatepushButton_font );
tpupdatepushButton->setText( tr( "Update" ) );
textLabel1 = new QLabel( this, "textLabel1" ); //stop
textLabel1->setGeometry( QRect( 410, 345, 40, 15 ) );
textLabel2 = new QLabel( this, "textLabel2" ); //start
textLabel2->setGeometry( QRect( 60, 345, 20, 15 ) );
textLabel2->setText( "0" );
textLabel3 = new QLabel( this, "textLabel3" );
textLabel3->setGeometry( QRect( 25, 330, 25, 15 ) );
textLabel3->setText( tr( "40M" ) );
textLabel4 = new QLabel( this, "textLabel4" );
textLabel4->setGeometry( QRect( 25, 265, 30, 15 ) );
textLabel4->setText( tr( "45M" ) );
textLabel6 = new QLabel( this, "textLabel6" );
textLabel6->setGeometry( QRect( 25, 195, 25, 15 ) );
textLabel6->setText( tr( "50M" ) );
textLabel7 = new QLabel( this, "textLabel7" );
textLabel7->setGeometry( QRect( 22, 125, 34, 15 ) );
textLabel7->setText( tr( "55M" ) );
textLabel8 = new QLabel( this, "textLabel8" );
textLabel8->setGeometry( QRect( 25, 55, 25, 15 ) );
textLabel8->setText( tr( "60M" ) );
textLabel9 = new QLabel( this, "textLabel9" );
textLabel9->setGeometry( QRect( 205, 3, 60, 15 ) );
textLabel9->setText( tr( "Throughput" ) );
textLabel10 = new QLabel( this, "textLabel10" ); //middle
textLabel10->setGeometry( QRect( 230, 345, 40, 15 ) );
connect ( this, SIGNAL( signaltpstopText(QString &) ), this, SLOT( showtabelpslot(QString &) ) );
connect ( this, SIGNAL( signaltpmiddleText(QString &) ), this, SLOT( showtabelmslot(QString &) ) );
connect( tpClosepushButton, SIGNAL( clicked() ), this, SLOT( close() ) );
}
void throutput(int sig)
{
int m= qblock/320 ; // count blocknum;
int xstep= int(370/m) ;
qtthrput=read(thrpipe[0],thrbuffer,BUFSIZ);// 从管道里读数据
*thput=atof(thrbuffer);
int a=a0+xstep;
int d = 340-(int)(0.000014*((*thput)-40000000));
paint->setPen(QPen(QColor( 48 ,93 ,255 )));
paint->drawLine ( a0, b0, a, d );
a0=a;
b0=d;
qy=d;
}
现在就是什么都不做,画图就会很顺利,如果最小化这个窗口,或者在打开其他窗口,画的数据线就不见了,55555555555伤心死了,各位大侠,帮帮忙,小妹在此万分感谢~><~ |
|