PDA

View Full Version : Mouse click event problem



impeteperry
2nd April 2007, 22:06
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 !
globalPos () const : const QPoint & if yes, how? or do I use one of the other
QMouseEvent ( Type type, const QPoint & position,
Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers ) type? again if so what does it look like.?

thanks

fullmetalcoder
2nd April 2007, 22:38
Within your reimplementation of QWidget::mouseDoubleClickEvent(QMouseEvent*) you should use QMouseEvent::pos() or QMouseEvent::globalPos() depending of what operations you want to perform...

drhex
3rd April 2007, 15:53
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.

impeteperry
4th April 2007, 14:44
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
connect(lwDataList, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this,
SLOT(slotFromListWidget(QListWidgetItem*))); which is basically what I want to do with the QMouseEvent pos(), but am confused with the actual syntex.

Thanks