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. QStyleOption Animation?
Forum Updated to NodeBB v4.3 + New Features

QStyleOption Animation?

Scheduled Pinned Locked Moved Unsolved General and Desktop
9 Posts 2 Posters 616 Views 2 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.
  • E Offline
    E Offline
    Ewan Green
    wrote on last edited by
    #1

    Hello. I'm trying to make a button inheriting from QPushButton that has multiple states, represented by which section of the button is highlighted. It might look something like this (on Windows 11):
    e306b596-e55d-4e0f-958f-c1a448de717f-image.png
    My plan is to use QStyleOptionButton to paint it to look native, and then to set a clip region and draw it again (but in the mouse over state).

    There is a problem when doing this, though; any animation a normal QPushButton may have gotten in when the mouse is entering/leaving it is now gone, and I'm not sure how to go about reimplementing it in a cross-platform way. I could store the two states as pixmaps and interpolate their colors, but that wouldn't look right on styles that don't have an animation.

    Thoughts?

    Ewan Green

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

      Hi,

      Wouldn't a set of custom QRadioButton be more adequate for that ?

      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
      • E Offline
        E Offline
        Ewan Green
        wrote on last edited by
        #3

        Having a collection of radio buttons doesn't look fantastic, in my opinion. Considering the way this widget is meant to be used in the context of the rest of the UI, something custom and very cohesively "in one piece" makes sense. I have also seen such buttons on the web, which arguably makes much more sense than in a situation where things are meant to look native, but I want to give it a shot anyway.

        I'm not sure that making a widget that inherits from QRadioButton would be my best course of action either, as I wouldn't really gain much other than the parent's "selected" state and maybe the ability to only have one active at a time while neighboring in a layout. I don't have a reason for choosing QPushButton specifically anyway, I just thought it the best option for creating a button-like thing since it already has keyboard navigation (though upon typing this, I realize the multi-state thing would be an issue...)

        I am open to other ideas on how to implement this widget /& collection of widgets. However, that still doesn't address the issue of animation.

        Ewan Green

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

          Should it be some kind of breadcrumb ?

          If I remember correctly, KDE might have some stuff for you.

          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
          • E Offline
            E Offline
            Ewan Green
            wrote on last edited by
            #5

            I've never heard the term breadcrumb in this context. Care to elaborate?
            As for the KDE stuff; I'd be willing to look into it, but at this point in time I do not want to rely on the KDE Frameworks. That's the kind of thing I'd be okay with when starting a project, you know?

            Ewan Green

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

              See here for small overview.

              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
              1
              • E Offline
                E Offline
                Ewan Green
                wrote on last edited by
                #7

                Oh, alright. Like Nautilus does for the path.
                No, it won't be like that. It would be kind of like how a sidebar behaves, it influences what's visible on the rest of the window. Mixing a sidebar with tabs would be kind of hard though, because the precedence of the state vs. whichever tab is open would be hard to illustrate in the UI. So I've decided on something like this.

                Ewan Green

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

                  So like the Qt Creator left sidebar ?

                  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
                  • E Offline
                    E Offline
                    Ewan Green
                    wrote on last edited by
                    #9

                    Yeah. The Qt Creator sidebar & a List View would be equivalent to this multi-state button & a tab widget. Each tab/list view item can be edited in multiple ways, dependent on the state (multi-state button’s current state or selected sidebar item, e.g. Edit, Debug, Design…). Hopefully that makes sense

                    Ewan Green

                    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