tanimbar
5th March 2008, 12:19
Hello,
I'm new to the forum and have a problem porting a science program from QT3.*.* on linux to qt4 on windows XP sp2. By the way, I'm an old fortran programmer and know little about Qt.
I have the program running correctly on Opensuse 10.2/Qt3.3.8.
For the code that doesn't work correctly on XP the user is supposed to:
1) Left-mouse select a point,
2) then hold down the left-mouse and drag an ellipse across an area of interest,
3) release the mouse and the underlying screen image is altered according to the ellipse area covered.
However, on the XP version the ellipse does not appear.
The relevent code is summarised below.
void strPlot::mousePressEvent( QMouseEvent *e)
pixmapa = QPixmap::grabWidget(this);
if ( e->button() == Qt::LeftButton )
//here I've left out that defines screen coords etc.
void strPlot::mouseMoveEvent( QMouseEvent *e)
{
int idx, nr_pryzmy;
QRect rr;
QPoint punkt;
int temp_x1,temp_z1,z_szer=0,z_wys=0;
double xm,zm;
QPainter p( this );
if(e->state() & Qt::LeftButton)
{
if(click_x1>click_x2)
{
temp_x1 = click_x2;
click_x2 = click_x1;
}
if(click_z1>click_z2)
{
temp_z1 = click_z2;
click_z2 = click_z1;
}
if(click_x1<xel) click_x1 = xel;
if(click_x2>xer) click_x2 = xer;
if(click_z1<yel) click_z1 = yel;
if(click_z2>yer) click_z2 = yer;
z_szer = click_x2 - click_x1;
z_wys = click_z2 - click_z1;
rr = QRect(temp_x1,temp_z1,z_szer,z_wys);
bitBlt(this,0,0,&pixmapa);
//rysuj_prostokaty(&p);
//repaint(rr);
p.setBrush(NoBrush);
p.setPen(QPen(black,2));
p.setPen(DashLine);
if(z_ksztalt==1 || z_ksztalt==-1) p.drawRect(rr);
if(z_ksztalt==2)p.drawEllipse(rr); // THIS IS THE BIT THAT FAILS
}
}
void strPlot::mouseReleaseEvent( QMouseEvent *e)
//here I've left out a lot of subsiduary code etc.
if(z_ksztalt==2)
{
rr = QRect(click_x1,click_z1,z_szer,z_wys) ;
zmien_stan(QRegion(rr,QRegion::Ellipse));
}
}
}
//Tanimbar: the update below causes the selected blocks to change density colour
update();
QPainter p( this );
rysuj_prostokaty(&p);
}
As I understand the code the following is supposed to happen:
1) on MousePressevent a pixmap is grabbed,
2) on MouseMovement the pixmap is passed to bitBlt and overdrawn on top of the, now, underlying widget,
3) while the Mouse is moving an ellipse should be drawn on the pixmap,
4) on Mousereleaseevent the pixmap disappears and the underlying widget is updated with new information, a colour change to blocks, formerly delineated by the ellipse.
However, after extensive trials, much reading of manuals and forums, I still cannot get the ellipse to become visible. Everything else works, including the events/actions required on MousereleaseEvent.
Can anyone help - hints, tips suggestions?
Thanks in advance.
I'm new to the forum and have a problem porting a science program from QT3.*.* on linux to qt4 on windows XP sp2. By the way, I'm an old fortran programmer and know little about Qt.
I have the program running correctly on Opensuse 10.2/Qt3.3.8.
For the code that doesn't work correctly on XP the user is supposed to:
1) Left-mouse select a point,
2) then hold down the left-mouse and drag an ellipse across an area of interest,
3) release the mouse and the underlying screen image is altered according to the ellipse area covered.
However, on the XP version the ellipse does not appear.
The relevent code is summarised below.
void strPlot::mousePressEvent( QMouseEvent *e)
pixmapa = QPixmap::grabWidget(this);
if ( e->button() == Qt::LeftButton )
//here I've left out that defines screen coords etc.
void strPlot::mouseMoveEvent( QMouseEvent *e)
{
int idx, nr_pryzmy;
QRect rr;
QPoint punkt;
int temp_x1,temp_z1,z_szer=0,z_wys=0;
double xm,zm;
QPainter p( this );
if(e->state() & Qt::LeftButton)
{
if(click_x1>click_x2)
{
temp_x1 = click_x2;
click_x2 = click_x1;
}
if(click_z1>click_z2)
{
temp_z1 = click_z2;
click_z2 = click_z1;
}
if(click_x1<xel) click_x1 = xel;
if(click_x2>xer) click_x2 = xer;
if(click_z1<yel) click_z1 = yel;
if(click_z2>yer) click_z2 = yer;
z_szer = click_x2 - click_x1;
z_wys = click_z2 - click_z1;
rr = QRect(temp_x1,temp_z1,z_szer,z_wys);
bitBlt(this,0,0,&pixmapa);
//rysuj_prostokaty(&p);
//repaint(rr);
p.setBrush(NoBrush);
p.setPen(QPen(black,2));
p.setPen(DashLine);
if(z_ksztalt==1 || z_ksztalt==-1) p.drawRect(rr);
if(z_ksztalt==2)p.drawEllipse(rr); // THIS IS THE BIT THAT FAILS
}
}
void strPlot::mouseReleaseEvent( QMouseEvent *e)
//here I've left out a lot of subsiduary code etc.
if(z_ksztalt==2)
{
rr = QRect(click_x1,click_z1,z_szer,z_wys) ;
zmien_stan(QRegion(rr,QRegion::Ellipse));
}
}
}
//Tanimbar: the update below causes the selected blocks to change density colour
update();
QPainter p( this );
rysuj_prostokaty(&p);
}
As I understand the code the following is supposed to happen:
1) on MousePressevent a pixmap is grabbed,
2) on MouseMovement the pixmap is passed to bitBlt and overdrawn on top of the, now, underlying widget,
3) while the Mouse is moving an ellipse should be drawn on the pixmap,
4) on Mousereleaseevent the pixmap disappears and the underlying widget is updated with new information, a colour change to blocks, formerly delineated by the ellipse.
However, after extensive trials, much reading of manuals and forums, I still cannot get the ellipse to become visible. Everything else works, including the events/actions required on MousereleaseEvent.
Can anyone help - hints, tips suggestions?
Thanks in advance.