Results 1 to 7 of 7

Thread: Mouse Events

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Mouse Events

    Skip the "A." part in the event handler - you are already in the "A" object.

  2. #2
    Join Date
    May 2008
    Posts
    20
    Thanks
    1

    Default Re: Mouse Events

    haha oh yea of course. then how about this:

    in the mouse event function:
    error: ‘((MyWidget*)this)->MyWidget:utline’ does not have class type


    Qt Code:
    1. // g++ rubber.cpp -o ss -lQtGui
    2.  
    3. #include <QtGui/QWidget>
    4. #include <QtGui/QDesktopWidget>
    5. #include <QtGui/QApplication>
    6. #include <QtGui/QPixmap>
    7. #include <QtGui/QRubberBand>
    8. #include <QtGui/QMouseEvent>
    9. #include <QtGui/QPushButton>
    10. #include <QtGui/QFont>
    11. #include <QtGui/QPainter>
    12.  
    13. #include <iostream>
    14.  
    15. using namespace std;
    16.  
    17. class MyWidget : public QWidget
    18. {
    19. public:
    20. MyWidget(QWidget *parent = 0);
    21. QRubberBand outline();
    22.  
    23. protected:
    24. void mousePressEvent(QMouseEvent *event);
    25.  
    26. };
    27.  
    28. MyWidget::MyWidget(QWidget *parent) : QWidget(parent)
    29. {
    30.  
    31. }
    32.  
    33. int main(int argc, char *argv[])
    34. {
    35. QApplication MyScreenshot(argc,argv);
    36. QPoint TopLeft(100,100);
    37. QPoint BottomRight(200,200);
    38. QRect SelectionRectangle(TopLeft, BottomRight);
    39.  
    40. MyWidget A();
    41. return MyScreenshot.exec();
    42. }
    43.  
    44. void MyWidget::mousePressEvent(QMouseEvent *event)
    45. {
    46.  
    47. QPoint TopLeft(100, 200);
    48. QPoint BottomRight(200,200);
    49. QRect SelectionRectangle(TopLeft, BottomRight);
    50. outline.setGeometry(SelectionRectangle);
    51. outline.show();
    52. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Mouse Events

    Quote Originally Posted by daviddoria View Post
    g++ rubber.cpp -o ss -lQtGui
    You should use qmake to generate a Makefile. Please, take a look at Qt Tutorial 1 (pay special attention to the qmake commands in the end).
    J-P Nurmi

Similar Threads

  1. Replies: 9
    Last Post: 22nd June 2008, 22:26
  2. Replies: 2
    Last Post: 2nd April 2008, 14:19
  3. mouse moving don't produce mouse events
    By coralbird in forum Qt Programming
    Replies: 1
    Last Post: 13th September 2006, 06:13
  4. QStackerWidget and mouse events
    By high_flyer in forum Qt Programming
    Replies: 3
    Last Post: 25th April 2006, 19:25
  5. Forwarding mouse events to another widget.
    By yogeshm02 in forum Qt Programming
    Replies: 8
    Last Post: 28th February 2006, 13:25

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
  •  
Qt is a trademark of The Qt Company.