Results 1 to 12 of 12

Thread: function to stop receiving event

  1. #1
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default function to stop receiving event

    hi
    is there any function to stop receiving events.(such that the events can be passed to the parents).

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: function to stop receiving event

    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

  3. #3
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Smile Re: function to stop receiving event

    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";
    }
    }

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: function to stop receiving event

    Install the event filter on list view's viewport. For example:
    Qt Code:
    1. ssl_listview->viewport()->installEventFilter(this);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    babu198649 (17th November 2007)

  6. #5
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: function to stop receiving event

    thanks jpn

    it works,

  7. #6
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: function to stop receiving event

    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

  8. #7
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: function to stop receiving event

    The most simple way is to use qDebug():
    Qt Code:
    1. #include <QtDebug>
    2.  
    3. bool ssl::eventFilter(QObject *obj, QEvent *ev)
    4. {
    5. qDebug() << ev;
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

  9. #8
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: function to stop receiving event

    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

  10. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: function to stop receiving event

    Quote Originally Posted by babu198649 View Post
    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?
    J-P Nurmi

  11. #10
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: function to stop receiving event

    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
    Attached Images Attached Images
    Last edited by babu198649; 19th November 2007 at 07:29.

  12. #11
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: function to stop receiving event

    Quote Originally Posted by babu198649 View Post
    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.

    [IMG]file:///home/user/Desktop/Untitled.xcf[/IMG]
    Attach image files, please.
    J-P Nurmi

  13. #12
    Join Date
    Nov 2007
    Posts
    291
    Thanks
    85
    Thanked 1 Time in 1 Post

    Default Re: function to stop receiving event

    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.

Similar Threads

  1. KDE/QWT doubt on debian sarge
    By hildebrand in forum KDE Forum
    Replies: 13
    Last Post: 25th April 2007, 06:13
  2. Link Errors
    By magikalpnoi in forum Qt Programming
    Replies: 5
    Last Post: 25th September 2006, 22:04
  3. use qpsql
    By raphaelf in forum Installation and Deployment
    Replies: 34
    Last Post: 22nd August 2006, 12:52
  4. Qt 4.1.4 plugin QPSQL
    By jcr in forum Installation and Deployment
    Replies: 4
    Last Post: 22nd June 2006, 22:55
  5. I got two problems when I used static compiled library of QT4
    By qintm in forum Installation and Deployment
    Replies: 8
    Last Post: 20th April 2006, 08:52

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.