Entry and exit signal syntax for qlistwidget[solved]



  • i am trying to implement a slot for whenever the mouse enters the vicinity of a list . but all the tries i have attempted have failed so far can you please tell me what is the correct syntax.

    i want a function to perform whenever the cursor enters the list it performs a particular function and when it leaves it shuts the function.

    i can implement the entered signal but there is no signal for leaving the list



  • do i have to use mouse events only cant i work with only signals for this


  • Lifetime Qt Champion

    Hi,

    You can reimplement the mouseEnterEvent and mouseLeaveEvent and emit a signal from there



  • thanks that is working in my application but when i try to implement it in a custom widget its showing the the event to be undefined



  • bool MyList::eventFilter(QObject* object, QEvent* event )
    {
    if (object==this)
    {
    if(event==QEvent::Enter)
    {
    for(int i=1;i<count();i++)
    {

                setRowHidden(i,false);
            }
            setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
            setMaximumHeight(60);
        }
        if(event->type()==QEvent::Leave)
        {
            for(int i=0;i<count()-1;i++)
            {
               setRowHidden(i,true);
            }
            setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
            setMaximumHeight(60);
            setMaximumHeight(20);
        }
    }
    return false;
    

    }


    i am implementing a class subclassing a qlistwidget


    C:\Qt\Qt5.0.1\Tools\QtCreator\bin\MyListPlugin\mylist.cpp:21: error: C2027: use of undefined type 'QEvent'
    '
    C:\Qt\Qt5.0.1\Tools\QtCreator\bin\MyListPlugin\mylist.cpp:21: error: C2227: left of '->type' must point to class/struct/union/generic type


    why is that
    cant events be implemented with widgets



  • thanks its working now .
    it seems i have to work with qwidgets class when subclassing for qwidget
    thank you sgaist


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.