TableView (QtQuick 2) with alternating row colors (DelegateChooser)

Johan Ouwerkerk jm.ouwerkerk at gmail.com
Thu Oct 22 17:47:49 BST 2020


On Tue, Oct 13, 2020 at 11:05 AM chiasa.men <chiasa.men at web.de> wrote:
>
> Thats the example from https://doc.qt.io/qt-5/qml-qt-labs-qmlmodels-tablemodel.html - Using DelegateChooser with TableModel
>
> I wonder how to enable alternating row colors. Usually in all Quick 2 Table
> codes Ive seen so far the background color is determined by a Rectangle in
> delegate.
>

You have a number of options, but importantly you should be able to
use the model index to select the appropriate colour.

>
> Furthermore: I want to use the TableView in a plasmoid configurtation.
> There the hierarchy lacks of an ApplicationWindow with specific height and
> width. Instead the TableView is wrapped by an Item.
> Is there a way to let the TableView fill the whole configuration window?
> At the moment I have to use:
>    Layout.preferredWidth:600
>    Layout.preferredHeight:400
> in order to show anything.
>
>   Layout.fillHeight: true
>   Layout.fillWidth: true
> Would not show anything
>

Again, you have a number of options here depending on your case some
of the following might work:

 - Instead of using a layout, use anchors.centerIn: parent, anchors.fill: parent
 - Binding an appropriate height/width and/or specifying an
appropriate implicitHeight/implicitWidth.

I would take a look at how other Plasmoids with a similar layout work
to see what works best for your case.

Regards,

- Johan Ouwerkerk


More information about the Kde-frameworks-devel mailing list