hi
is there any function to stop receiving events.(such that the events can be passed to the parents).
hi
is there any function to stop receiving events.(such that the events can be passed to the parents).
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.
J-P Nurmi
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";
}
}
Install the event filter on list view's viewport. For example:
Qt Code:
ssl_listview->viewport()->installEventFilter(this);To copy to clipboard, switch view to plain text mode
J-P Nurmi
babu198649 (17th November 2007)
thanks jpn
it works,
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
The most simple way is to use qDebug():
Qt Code:
#include <QtDebug> { qDebug() << ev; ... }To copy to clipboard, switch view to plain text mode
J-P Nurmi
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
Sorry, I forgot to mention that you will have to #include <QtGui> to get more detailed output.
How does QListView "expand"? I thought only QTreeView has such functionality..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
Sorry, I don't understand the explanation. The event never reaches its destination if the event filter returns true.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 .
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?
J-P Nurmi
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.How does QListView "expand"? I thought only QTreeView has such functionality..
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
Last edited by babu198649; 19th November 2007 at 07:29.
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.
Attach image files, please.[IMG]file:///home/user/Desktop/Untitled.xcf[/IMG]
J-P Nurmi
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.
yes i was actually mentioning the same(should i have mentioned it as a signal).So why not use QAbstractItemView::doubleClicked()?
please read the above post once more.
Bookmarks