DenverCoder21
DenverCoder21

Reputation: 887

Color of Rectangle in ScrollView not shown

I'm wondering why the color of the rectangle inside my ScrollView is not being shown, but the text of the Text is. Do I have to make my Rectangle a Flickable?

import QtQuick 2.5
import QtQuick.Controls 1.4

ApplicationWindow {
  visible: true
  width: 640
  height: 480
  title: qsTr("Hello World")
  color: "#00ff00"

  menuBar: MenuBar {
    Menu {
      title: qsTr("File")
      MenuItem {
        text: qsTr("&Open")
        onTriggered: console.log("Open action triggered");
      }
      MenuItem {
        text: qsTr("Exit")
        onTriggered: Qt.quit();
      }
    }
  }

  Rectangle {
    id: motherOfGod
    color: "#554455"

    width: 400
    height: 400

    anchors.centerIn: parent

    TabView {
      anchors.fill: parent

      Tab {
        title: "Red"
        ScrollView {
          Rectangle {
            color: "red"
            height: 1200
            anchors {
              top: parent.top
              left: parent.left
              right: parent.right
            }

            Text { text: "I'm in the red tab" }
          }
        }
      }
      Tab {
        title: "Green"
        Rectangle { color: "green" }
      }
      Tab {
        title: "Blue"
        Rectangle { color: "blue" }
      }
    }
  }
}

Upvotes: 1

Views: 49

Answers (1)

thomas
thomas

Reputation: 330

Try:

ScrollView {
  Rectangle {
    color: "red"
    height: 1200
    width: viewport.width
    Text { text: "I'm in the red tab" }
  }
}

Upvotes: 1

Related Questions