PDA

View Full Version : function to stop receiving event



babu198649
17th November 2007, 08:26
hi
is there any function to stop receiving events.(such that the events can be passed to the parents).

jpn
17th November 2007, 10:36
Could you elaborate the problem a bit, please? What do you actually want to do? Presumably you already found event filters since you're talking about them in this other recent thread (http://www.qtcentre.org/forum/f-qt-programming-2/t-qdirmodel-installeventfilter-10244.html).

babu198649
17th November 2007, 10:58
thanks
hi
actually i want to capture the mouse press event.

i have used event filer to filter signals on listview .but the mouse events cannot be caught .is this because they are inbuilt signals(such as clicked e.t.c).

here is the code

QListView *ssl_listview
ssl_listview = new QListView();
bool ssl::eventFilter(QObject *obj, QEvent *ev)
{
if(obj == ssl_listview)
{
if(ev->type() == QEvent::MouseButtonPress)
cout<<"mouse press";
}
}

jpn
17th November 2007, 11:02
Install the event filter on list view's viewport. For example:

ssl_listview->viewport()->installEventFilter(this);

babu198649
17th November 2007, 11:38
thanks jpn

it works,:)

babu198649
17th November 2007, 11:43
now i can receive the event types enumeration constant ,but can we get the enumeration type of event (not constant )in QString.

ie.
bool ssl::eventFilter(QObject *obj, QEvent *ev)
{
int constant = ev->type() ; //ex 2 if it is QEvent::MouseButtonPress
}

but can i print the QEvent::MouseButtonPress

jpn
17th November 2007, 11:53
The most simple way is to use qDebug() (http://doc.trolltech.com/4.3/qtglobal.html#qDebug):


#include <QtDebug>

bool ssl::eventFilter(QObject *obj, QEvent *ev)
{
qDebug() << ev;
...
}

babu198649
17th November 2007, 12:15
thanks again :)
it works but what is the hexadecimal numbers indicate in the output such as this

QEvent(0x815130, type = 77)
QEvent(0x80f3d0, type = 77)
QEvent(0x83be90, type = 77)
QEvent(0x7fa3e0, type = 77)
QEvent(0x7fff59399510, type = 18)
QEvent(0x7fff59399510, type = 18)
QEvent(0x7fff59399510, type = 18)


and
actually i have set QDirModel for the Qlistview .
even after installing the filter for the view port of QListView , though it can not expand the directories on double click

it still identifies when i click on the listview viewport (because when i click on the view port the directory name is highlighted by a dotted line ). so where does the event go at first.

i am intrested in finding the event propagation without installation because i dont want to miss any hidden events . is there any way .

thanks again

jpn
18th November 2007, 09:17
it works but what is the hexadecimal numbers indicate in the output such as this
Sorry, I forgot to mention that you will have to #include <QtGui> to get more detailed output.


actually i have set QDirModel for the Qlistview .
even after installing the filter for the view port of QListView , though it can not expand the directories on double click
How does QListView "expand"? I thought only QTreeView has such functionality.. :)


it still identifies when i click on the listview viewport (because when i click on the view port the directory name is highlighted by a dotted line ). so where does the event go at first.

i am intrested in finding the event propagation without installation because i dont want to miss any hidden events . is there any way .
Sorry, I don't understand the explanation. The event never reaches its destination if the event filter returns true.

In my humble opinion, event filter is a wrong way to implement such functionality anyway. You should consider subclassing QListView, reimplementing appropriate event handlers and calling base class implementation to keep it in sync. Oh, and why is signal QAbstractItemView::pressed() insufficient?

babu198649
19th November 2007, 07:17
How does QListView "expand"? I thought only QTreeView has such functionality..

oh sorry i forgot to mention that i have made it to display the subdirectories on double click by capturing the double click of QListView.

i have installed the event filter for the listview and the list view is added to QStackedWidget.
when the listview is clicked (event filter returns true for this event in event filter member function) the file name is shown in dotted line .i have attached the file(the dotted line which i am referring is marked)



this means that event has not been filtered . how to filter this event.





thanks for reply:)

jpn
19th November 2007, 07:28
oh sorry i forgot to mention that i have made it to display the subdirectories on double click by capturing the double click of QListView.

i have installed the event filter for the listview and the list view is added to QStackedWidget.
when the listview is clicked (event filter returns true for this event in event filter member function) the file name is shown in dotted line as shown in following figure.
this means that event has not been filtered . how to filter this event.
So why not use QAbstractItemView::doubleClicked()? It's much easier to use and less error prone than filtering corresponding events by hand. You can use QWidget::setFocusPolicy() if you don't want the view to receive focus.


file:///home/user/Desktop/Untitled.xcf
Attach image files, please.

babu198649
19th November 2007, 08:45
i have attached the file and after posting i found that the files have been not attached and
edited the post,in the mean while u have replied(thanks)for my post.


So why not use QAbstractItemView::doubleClicked()?
yes i was actually mentioning the same(should i have mentioned it as a signal).

please read the above post once more.