Results 1 to 8 of 8

Thread: disabling mouse event

  1. #1
    Join Date
    Aug 2008
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default disabling mouse event

    is it possible to disable mouse enter and leave events

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 975 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: disabling mouse event

    You can use an event filter to filter them out.

  3. #3
    Join Date
    Aug 2008
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: disabling mouse event

    i tried that. i have my own label classes. and im drawing graphs on that labels.

    when mouse enter and leave events happens on those labels, paint event still being called. but i want the paint event to be called only with my signal.

    in constructor:
    emi_label->installEventFilter(this);
    gpr_label->installEventFilter(this);
    Qt Code:
    1. bool mainWidget::eventFilter(QObject *obj, QEvent *event)
    2. {
    3. if(event->type() == QEvent::Enter || event->type() == QEvent::Leave){
    4. if(obj == this){
    5. qDebug("warning: main event");
    6. }
    7. if(obj == emi_label){
    8. qDebug("warning: emi event");
    9. }
    10. if(obj == gpr_label){
    11. qDebug("warning: gpr event");
    12. }
    13. }
    14. return false;
    15. }
    To copy to clipboard, switch view to plain text mode 

    event catches are right as far as i can see. i see expected warnings on terminal
    Qt Code:
    1. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
    2. void gprLabel::update_gui(){
    3.  
    4. if(is_gpr_data_ready){
    5. for(int i=101;i<=228;i++){
    6. gpr_matrix[gpr_matrix_index][i-101] = rand()%256;
    7. }
    8. gpr_matrix_index++;
    9. is_gpr_data_ready = 0;
    10. }
    11.  
    12. if(gpr_matrix_index == vWIDTH ){
    13. gpr_matrix_index = 0;
    14. is_ready_to_draw = 1;
    15. update();
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    as u see i want gpr_label to be updated only with my call. how can do that
    Last edited by jacek; 16th September 2008 at 20:22. Reason: missing [code] tags

  4. #4
    Join Date
    Sep 2008
    Location
    Tver, Russia
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: disabling mouse event

    Assistant:
    if you want to filter the event out, i.e. stop it being handled further, return true;
    bool mainWidget::eventFilter(QObject *obj, QEvent *event)
    {
    if(event->type() == QEvent::Enter || event->type() == QEvent::Leave)
    {

    if(obj == this)
    {
    qDebug("warning: main event");
    }
    if(obj == emi_label)
    {
    qDebug("warning: emi event");
    return true;
    }
    if(obj == gpr_label)
    {
    qDebug("warning: gpr event");
    return true;
    }
    }
    return QMainWindow::eventFilter(obj, event);
    }

  5. #5
    Join Date
    Aug 2008
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: disabling mouse event

    when i do that, my labels become invisiable. i dont see any of them.

    also im getting error if i use QMainWindow::eventFilter(). "cannot call member function without object..."

  6. #6
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: disabling mouse event

    Is your mainwidget derived from QMainWindow ??
    Also why do u want to call other eventfilter from ur filter ?
    just return true or false

  7. #7
    Join Date
    Aug 2008
    Posts
    11
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: disabling mouse event

    i was referring to the code above my last post.

    the important thing now is if i return true my labels become invisible.

  8. #8
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: disabling mouse event

    I guess I am missing something in understanding ur problem...
    u want to paint only when ur signal is emitted, right ? You can hold a variable and update it on the signal emitted. Use this variable in paint event.
    May be i am wrong in understanding..

    can u tell me if i am getting ur prob right.. cud u please explain a bit more of what u actually wanna do ?

Similar Threads

  1. StyleSheets: border-image performance
    By GuS in forum Qt Programming
    Replies: 3
    Last Post: 15th May 2013, 12:42
  2. Tabbed widget performance suggestions
    By MrGarbage in forum Qt Programming
    Replies: 0
    Last Post: 8th December 2007, 16:02
  3. Replies: 1
    Last Post: 4th October 2006, 16:05
  4. [QT 4] QTextEdit performance
    By fellobo in forum Qt Programming
    Replies: 8
    Last Post: 6th March 2006, 19:27

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.