My button's fail



  • if i have not writer installEventFilter in father widget,my button's qss is succeed,but when i writer installEventFilter,my button 's qss fail, for instance,
    @
    m_CompanyBrand->setStyleSheet("QPushButton:hover{background-image:url(:/image/tatile1.png);} QPushButton{background-image:url(:/image/tatile2.png);} ");
    @

    Edit: please use @ tags around code sections; Andre


  • Lifetime Qt Champion

    Hi and welcome to DevNet,

    Could you show the code of your event filter ? You most likely eat all events in there so the button probably misses QEvent::StyleChange

    Hope it helps



  • my code is
    @
    bool ViperFrame::eventFilter(QObject *obj, QEvent *event)
    {
    if(obj == this)
    {
    if (event->type() == QEvent::MouseButtonPress)
    {
    m_aFrame->hide();
    return true;
    }
    }
    }

    @

    Edit: Again, @ tags around code sections please; Andre


  • Moderators

    Don't omit return value. This is undefined behavior and it's a shame that some compilers allow you to compile that.
    Explicitly return false at the end of your eventFilter.

    Also, as SGaist said, you are eating the event by returning true. You should probably return false to let Qt handle it properly or call the base implementation yourself.



  • NOW ,i Meet with difficulties, i build a tablewidget,
    @
    m_tableWidget = new QTableWidget(100,100,fatherWidget);
    m_tableWidget->setGeometry(430,75,1490,1005);
    @
    when i write
    @
    m_tableWidget->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{border:0px solid grey; width:20px;} QScrollBar::handle:vertical{background-color : rgb(51,89,128);border:0px;min-height:5px;} QScrollBar::add-page:vertical{background-color: rgb(62,86,112);} QScrollBar::sub-page:vertical {background-color: rgb(62,86,112);}");
    @
    The verticalScrollBar can't display in my widget, but when i Comment code ,verticalScrollBar display, please tell me the reason.by the way , i can't also control verticalScrollBar'haddle's heigh, although i write min-height:5px. thanke you

    Edit: @ tags...; Andre



  • i have soluted qustion of displaying verticalScrollBar,but i can't also control verticalScrollBar's height.min-height:5px or min-height:10px , the verticalScrollBar's handle's height is the same height.


Log in to reply
 

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