Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Rectangle instead of BackgroundImage as scrollbar handle for a TableView?
QtWS25 Last Chance

Rectangle instead of BackgroundImage as scrollbar handle for a TableView?

Scheduled Pinned Locked Moved QML and Qt Quick
3 Posts 2 Posters 1.1k Views
  • 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.
  • D Offline
    D Offline
    DaWoo
    wrote on last edited by
    #1

    Hi,

    I am currently developing using Qt 5.1.1.

    I need to implement a custom style for a "TableView". Thus I define a new TableViewStyle for my TableView including delegates: itemDelegate, headerDelegate, handle etc.

    When defining the scrollbar handle delegate I tried first to define it as a simple Rectangle with a certain background color. This did not work, the scrollbar handle was not visible.
    When i use Image or BackgroundImage all is fine. Can anybody explain to me why I can't use a Rectangle here?

    Also, I had trouble to find good documentation concerning the TableViewStyle. I had to gather a lot of information from the code. Am I missing a source of documentation?

    Some code for explanation:

    @TableView {
    model : id_dbaseLibModel
    style : TableViewStyle
    {
    itemDelegate: id_itemDelegate
    headerDelegate: id_headerDelegate
    rowDelegate: id_rowDelegate

                minimumHandleLength: 20
                handleOverlap: 5
    
                /* not working: 
                handle:  Rectangle {
                    width: 10;   
                    color: "black"; 
                }
                */
    
                /* working fine: */
                handle:  Image
                {
                    source: "/gfx/icons/naviOff.png"  // random image, temporary
                }
    
                decrementControl: Component { Rectangle{} }
                incrementControl: Component { Rectangle{} }
    
                scrollBarBackground : Rectangle { width: 10;  color: "green" }
            }
    
    TableViewColumn{ ..... }
    TableViewColumn{ ..... }
    

    }
    @

    Thx
    DaWoo

    1 Reply Last reply
    0
    • T Offline
      T Offline
      Torgeir
      wrote on last edited by
      #2

      Hi,

      I use this, and it works for me:
      @
      handle: Rectangle {
      implicitWidth: 8
      implicitHeight: 8
      color: "black"
      }
      @

      1 Reply Last reply
      0
      • D Offline
        D Offline
        DaWoo
        wrote on last edited by
        #3

        Hi Torgeir,

        your handle definition works for me also. It seems to be important to define the implicitWidth of the handle instead of just the width.
        From the documentation I understand that the implicitWidth of an item is 0 by default, wich would explain why the scrollbar handle (as i defined it) was not visible.

        What I don't understand though: why is the "explicit" width ignored in this case?

        Thanks
        DaWoo

        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