Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. My button's fail
Qt 6.11 is out! See what's new in the release blog

My button's fail

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 2.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    foxgod
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • F Offline
        F Offline
        foxgod
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • Chris KawaC Offline
          Chris KawaC Offline
          Chris Kawa
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • F Offline
            F Offline
            foxgod
            wrote on last edited by
            #5

            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

            1 Reply Last reply
            0
            • F Offline
              F Offline
              foxgod
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved