Results 1 to 4 of 4

Thread: QT3 to Qt4 port - problem seeing Ellipse etc

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2008
    Posts
    3
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default QT3 to Qt4 port - problem seeing Ellipse etc

    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.


    Qt Code:
    1. void strPlot::mousePressEvent( QMouseEvent *e)
    2. pixmapa = QPixmap::grabWidget(this);
    3.  
    4. if ( e->button() == Qt::LeftButton )
    5. //here I've left out that defines screen coords etc.
    6.  
    7.  
    8.  
    9. void strPlot::mouseMoveEvent( QMouseEvent *e)
    10. {
    11.  
    12. int idx, nr_pryzmy;
    13. QRect rr;
    14. QPoint punkt;
    15. int temp_x1,temp_z1,z_szer=0,z_wys=0;
    16. double xm,zm;
    17.  
    18. QPainter p( this );
    19.  
    20. if(e->state() & Qt::LeftButton)
    21. {
    22. if(click_x1>click_x2)
    23. {
    24. temp_x1 = click_x2;
    25. click_x2 = click_x1;
    26. }
    27.  
    28. if(click_z1>click_z2)
    29. {
    30. temp_z1 = click_z2;
    31. click_z2 = click_z1;
    32. }
    33.  
    34. if(click_x1<xel) click_x1 = xel;
    35. if(click_x2>xer) click_x2 = xer;
    36. if(click_z1<yel) click_z1 = yel;
    37. if(click_z2>yer) click_z2 = yer;
    38.  
    39. z_szer = click_x2 - click_x1;
    40. z_wys = click_z2 - click_z1;
    41.  
    42. rr = QRect(temp_x1,temp_z1,z_szer,z_wys);
    43.  
    44. bitBlt(this,0,0,&pixmapa);
    45.  
    46. //rysuj_prostokaty(&p);
    47. //repaint(rr);
    48. p.setBrush(NoBrush);
    49. p.setPen(QPen(black,2));
    50. p.setPen(DashLine);
    51. if(z_ksztalt==1 || z_ksztalt==-1) p.drawRect(rr);
    52.  
    53. if(z_ksztalt==2)p.drawEllipse(rr); // THIS IS THE BIT THAT FAILS
    54.  
    55. }
    56. }
    57.  
    58. void strPlot::mouseReleaseEvent( QMouseEvent *e)
    59.  
    60. //here I've left out a lot of subsiduary code etc.
    61.  
    62. if(z_ksztalt==2)
    63. {
    64. rr = QRect(click_x1,click_z1,z_szer,z_wys) ;
    65. zmien_stan(QRegion(rr,QRegion::Ellipse));
    66.  
    67. }
    68. }
    69. }
    70. //Tanimbar: the update below causes the selected blocks to change density colour
    71. update();
    72. QPainter p( this );
    73. rysuj_prostokaty(&p);
    74. }
    To copy to clipboard, switch view to plain text mode 

    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.
    Last edited by wysota; 5th March 2008 at 12:47.

Similar Threads

  1. problem while compiling qextserial port
    By jjbabu in forum Qt Programming
    Replies: 1
    Last Post: 15th September 2007, 13:01
  2. Replies: 6
    Last Post: 18th April 2007, 15:04
  3. Replies: 16
    Last Post: 7th March 2006, 15:57

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.