Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qt-interest Archive, April 2007
Generating mouse events in Qt


Message 1 in thread

Hello,

Can anyone help me resolve this issue:  how can I generate a mouse press or mouse move event in
QT?

Is it sufficient to create a QMouseEvent object as follows from a data
thread to GUI thread :

/* After calculating x & y values from serial port */

QCustomEvent *ev=new QCustomEvent(123);
ev->setData(new
QMouseEvent(QEvent::MouseMove,p,Qt::NoButton,Qt::NoButton));

In the receiver thread (GUI), we handle the event as follows:

switch(event->type())
{
        case 123: QMouseEvent *e=(QMouseEvent *)event->data();
                                            int x=e->x();
                                            int y=e->y();
                                            QPoint pt(x,y);
                                            QCursor c=this->cursor();
                                            c.setPos(*p);
                                            break;
..

}

Kindly let us know how to create a mouse press event in Qt, recognized by
the GUI?

Thanks

Message 2 in thread

On Monday 02 April 2007 17:10, Pankaj wrote:
> Kindly let us know how to create a mouse press event in Qt, recognized by
> the GUI?

I think you are half way there. If I'm not mistaking the event you created 
should also be posted to the event queue.

See the static method:  QCoreApplication::postEvent
-- 
 [ signature omitted ] 

Attachment: pgpgYryQiLd9o.pgp
Description: PGP signature


Message 3 in thread

Hello,
Thanks, Thomas. Yes, I am creating an event to be posted to event  
queue. But, I have tried using postEvent, but it did not work.

Given, a set of x and y values, how can we create a QMouseEvent object  
and send it to the GUI and execute an event handler for a push button?

I have written even handlers for each of the buttons that handle mouse  
click events. As I am not using the mouse, I am trying to generate a  
mouse event (press and released).

How can I generate these events and invoke the event handlers (slots)  
that I have created for the mouse events?

Thanks,

Pankaj.
Quoting Thomas Zander <zander@xxxxxxx>:

> On Monday 02 April 2007 17:10, Pankaj wrote:
>> Kindly let us know how to create a mouse press event in Qt, recognized by
>> the GUI?
>
> I think you are half way there. If I'm not mistaking the event you created
> should also be posted to the event queue.
>
> See the static method:  QCoreApplication::postEvent
> --
> Thomas Zander
>



--
 [ signature omitted ] 

Message 4 in thread

Hi,

I need to set a model to a qcombobox to manage item text in the combo 
and listview shown when user click combo arrow.

I don't understand how to knox what model item is selected.
I connect the activated (int) signal to a slot.
but how can I get model datas with the index of the signal.

And how can I control the insertion of new item.
I understand that when I insertrow the row is prepended, I want to 
append it.


than for help to a newbie in model/view usage.


Veronique.

--
 [ signature omitted ] 

Message 5 in thread

Hi,

  You can use the QComboBox::model() method to retrieve the model attached 
to your combo box. Then using the index(int row, int column, QModelIndex & 
parent) method ( which should have been reimplemented ), you can retrieve 
the QModelIndex matching the signal index.
  To control the item insertion, we shall use beginInsertRows() - 
endInsertRows() methods, passing in first and last index.

  Regards

  Eric

>From: veronique.lefrere@xxxxxx
>To: qt-interest@xxxxxxxxxxxxx
>Subject: qcombobox model and selection question
>Date: Mon, 02 Apr 2007 17:44:05 +0200
>
>Hi,
>
>I need to set a model to a qcombobox to manage item text in the combo and 
>listview shown when user click combo arrow.
>
>I don't understand how to knox what model item is selected.
>I connect the activated (int) signal to a slot.
>but how can I get model datas with the index of the signal.
>
>And how can I control the insertion of new item.
>I understand that when I insertrow the row is prepended, I want to append 
>it.
>
>
>than for help to a newbie in model/view usage.
>
>
>Veronique.
>
>--
>To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
>"unsubscribe" in the subject or the body.
>List archive and information: http://lists.trolltech.com/qt-interest/
>

_________________________________________________________________
Gagnez des écrans plats avec Live.com http://www.image-addict.fr/

--
 [ signature omitted ]