Results 1 to 4 of 4

Thread: Mouse click event problem

  1. #1
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Mouse click event problem

    I am programming using Qt-4.2.3 on a "kubuntu7.04" linux distro.
    I have MAJOR problems understanding some of the Qt4 documentation where there is no "code examples" of which there are very few in Qt4.

    so

    I have a drawing area "frmDrawing" with various items on it. I want to get the position of the mouse when I double click the left mouse button.

    Do I use !
    Qt Code:
    1. globalPos () const : const QPoint &
    To copy to clipboard, switch view to plain text mode 
    if yes, how? or do I use one of the other
    Qt Code:
    1. QMouseEvent ( Type type, const QPoint & position,
    2. Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers )
    To copy to clipboard, switch view to plain text mode 
    type? again if so what does it look like.?

    thanks
    Last edited by jacek; 2nd April 2007 at 21:39. Reason: wrapped too long line

  2. #2
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mouse click event problem

    Within your reimplementation of QWidget::mouseDoubleClickEvent(QMouseEvent*) you should use QMouseEvent::pos() or QMouseEvent::globalPos() depending of what operations you want to perform...
    Current Qt projects : QCodeEdit, RotiDeCode

  3. The following user says thank you to fullmetalcoder for this useful post:

    impeteperry (4th April 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Mouse click event problem

    There is an "examples" directory with plenty of examples of how to code in QT4 that should have been part of the Qt package you downloaded.

  5. The following user says thank you to drhex for this useful post:

    impeteperry (4th April 2007)

  6. #4
    Join Date
    Jan 2006
    Location
    Riverside, Rhode Island, USA
    Posts
    245
    Thanks
    52
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Mouse click event problem

    Thanks I didn't have my e-mail notification set.
    I am working alone. I don't know anybody programming except thru these forums.

    I have looked at all the examples and demos many times, but they are not "command indexed" As someone trying to learn Ot. I find somthing like this most helpful in addition to the examples.
    void QList::swap ( int i, int j )

    Exchange the item at index position i with the item at index position j.

    Example:

    QList<QString> list;
    list << "A" << "B" << "C" << "D" << "E" << "F";
    list.swap(1, 4);
    // list: ["A", "E", "C", "D", "B", "F"]

    See also move
    An example from my code
    Qt Code:
    1. connect(lwDataList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
    2. SLOT(slotFromListWidget(QListWidgetItem*)));
    To copy to clipboard, switch view to plain text mode 
    which is basically what I want to do with the QMouseEvent pos(), but am confused with the actual syntex.

    Thanks

Similar Threads

  1. The event fired by the mouse click on the frame
    By Placido Currò in forum Qt Programming
    Replies: 8
    Last Post: 3rd March 2007, 09:05
  2. Mouse Over event on button
    By vishal.chauhan in forum Qt Programming
    Replies: 9
    Last Post: 10th January 2007, 05:03
  3. mouse click in QGprahicsScene
    By Morea in forum Qt Programming
    Replies: 11
    Last Post: 21st December 2006, 08:21
  4. event problem
    By windkracht8 in forum Qt Programming
    Replies: 5
    Last Post: 17th August 2006, 11:52
  5. mouse click event
    By vijay anandh in forum Qt Programming
    Replies: 1
    Last Post: 1st May 2006, 09:24

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.