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. Strange stylesheet behavior with QListView::item
Forum Updated to NodeBB v4.3 + New Features

Strange stylesheet behavior with QListView::item

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 7.1k 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.
  • JonBJ JonB

    @raven-worx
    Given what you've said (I've noted before what you've said about QSS! :) ), an item in a QListViewis of class QListViewItem, so could this be rewritten to work as:

    QListView#menuListView QListViewItem {

    ?

    raven-worxR Offline
    raven-worxR Offline
    raven-worx
    Moderators
    wrote on last edited by
    #4

    @JonB said in Strange stylesheet behavior with QListView::item:

    an item in a QListViewis of class QListViewItem, so could this be rewritten to work as

    no, stylesheets get only applied/inherited to QWidgets.

    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
    If you have a question please use the forum so others can benefit from the solution in the future

    1 Reply Last reply
    0
    • raven-worxR raven-worx

      @qwasder85 said in Strange stylesheet behavior with QListView::item:

      QListView#menuListView::item {
      padding-left: 10;
      }

      Basically this syntax should be correct, but unfortunately Qt stylesheet parsing isn't all the time.

      Just for testing: does style rule get applied when you remove the objectname selector part?

      qwasder85Q Offline
      qwasder85Q Offline
      qwasder85
      wrote on last edited by
      #5

      @raven-worx Same behavior without the object name.

      raven-worxR 1 Reply Last reply
      0
      • qwasder85Q qwasder85

        @raven-worx Same behavior without the object name.

        raven-worxR Offline
        raven-worxR Offline
        raven-worx
        Moderators
        wrote on last edited by
        #6

        @qwasder85
        When do you set the stylesheet exactly?

        --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
        If you have a question please use the forum so others can benefit from the solution in the future

        qwasder85Q 1 Reply Last reply
        0
        • raven-worxR raven-worx

          @qwasder85
          When do you set the stylesheet exactly?

          qwasder85Q Offline
          qwasder85Q Offline
          qwasder85
          wrote on last edited by
          #7

          @raven-worx said in Strange stylesheet behavior with QListView::item:

          @qwasder85
          When do you set the stylesheet exactly?

          I set it application-wide in the main.

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

            Hi
            It works for me on win 10, Qt 5.10
            alt text
            Stylesheet applied directly on listview

            qwasder85Q 1 Reply Last reply
            2
            • mrjjM mrjj

              Hi
              It works for me on win 10, Qt 5.10
              alt text
              Stylesheet applied directly on listview

              qwasder85Q Offline
              qwasder85Q Offline
              qwasder85
              wrote on last edited by
              #9

              @mrjj Sorry, I don't see the relevance.
              Have you tried applying the stylesheet I posted to a listview directly? Because this doesn't work either in my case.
              Did you post a wrong screenshot by any chance?

              mrjjM 1 Reply Last reply
              0
              • qwasder85Q qwasder85

                @mrjj Sorry, I don't see the relevance.
                Have you tried applying the stylesheet I posted to a listview directly? Because this doesn't work either in my case.
                Did you post a wrong screenshot by any chance?

                mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by
                #10

                Hi
                It shows that ::item also works with # selector as
                i apply the gradient with style sheet as seen in shot.

                I was not sure if padding would be visible easy in icon mode
                so i used grad instead.

                so maybe the ::item do not support
                padding-left

                I will try that directly tonight.

                qwasder85Q 1 Reply Last reply
                0
                • mrjjM mrjj

                  Hi
                  It shows that ::item also works with # selector as
                  i apply the gradient with style sheet as seen in shot.

                  I was not sure if padding would be visible easy in icon mode
                  so i used grad instead.

                  so maybe the ::item do not support
                  padding-left

                  I will try that directly tonight.

                  qwasder85Q Offline
                  qwasder85Q Offline
                  qwasder85
                  wrote on last edited by qwasder85
                  #11

                  @mrjj It definitely supports padding, it does so in the "selected" and "hover" states without any issue. I can also eliminate a conflict with inheritance, since the behavior stays the same when I deactivate my application-wide stylesheet and set it for the table view directly.

                  1 Reply Last reply
                  0
                  • webzoidW Offline
                    webzoidW Offline
                    webzoid
                    wrote on last edited by
                    #12

                    @qwasder85 I also can't get your stylesheet to apply to a QListView however, as a "hack", if you use border-left:10px solid transparent, you should get the padding you need. I know it's not right and it's not pretty but it works.

                    qwasder85Q 1 Reply Last reply
                    1
                    • webzoidW webzoid

                      @qwasder85 I also can't get your stylesheet to apply to a QListView however, as a "hack", if you use border-left:10px solid transparent, you should get the padding you need. I know it's not right and it's not pretty but it works.

                      qwasder85Q Offline
                      qwasder85Q Offline
                      qwasder85
                      wrote on last edited by qwasder85
                      #13

                      @webzoid haha, I'll keep it in mind.

                      So, this is apparently a bug? I don't see where I did something wrong within the stylesheet.

                      webzoidW 1 Reply Last reply
                      0
                      • qwasder85Q qwasder85

                        @webzoid haha, I'll keep it in mind.

                        So, this is apparently a bug? I don't see where I did something wrong within the stylesheet.

                        webzoidW Offline
                        webzoidW Offline
                        webzoid
                        wrote on last edited by
                        #14

                        @qwasder85 It would indeed appear to be a bug.

                        Your stylesheet seems correct and I would expect the padding-left to be applied as per your CSS however in this instance (and bizarrely, only when hovering) it doesn't get applied.

                        Maybe raise it as a bug through the official channels?

                        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