Details
-
Bug
-
Resolution: Done
-
Not Evaluated
-
5.7.0
-
None
-
Mac OSX 10.11.6, Windows 10
-
0d255307d26de786ba7535d76ac6f27c4c139d5e
Description
When a QML ChartView is reparented to another Window's contentItem it becomes invisible until changed visually in some way.
Below is the QML used to recreate this issue. I've also attached a full project file for convenience.
// Instructions
- Run the project.
- Click "Create SubWindow"
- Click "Reparent Chart"
*NOTE* - The chart has been reparented but is invisible. - Click "Change Value" OR click on where the chart should be located (center of the subWindow). This will cause the chart to reappear.
// Info
- The ChartView is not set as invisible or to zero opacity.
- The CharView's geometry remains constant.
- Removing the anchors has no effect.
- If a plain red Rectangle is added as a child to the ChartView, it is moved over successfully and is visible. It is only the chart drawing that is not displayed.
Please let me know of any potential workaround for this issue or if there is anything i can do to help resolve it.
main.qml
import QtQuick 2.7 import QtQuick.Window 2.2 import QtQuick.Controls 2.0 import QtCharts 2.0 import QtQuick.Layouts 1.3 // Window { id: mainWindow visible: true width: 640 height: 480 title: qsTr("Hello ChartTest") // Private Properties property Window __subWindow: null; // Private Methods function __createSubWindow() { mainWindow.__subWindow = subWindowComponent.createObject(); console.assert(mainWindow.__subWindow !== null); } Component { id: subWindowComponent Window { visible: true x: 10 y: 10 height: 200 width: 200 } } RowLayout { Button { id: popButton text: "Create SubWindow" onClicked: mainWindow.__createSubWindow(); } Button { id: reparentButton text: "Reparent Chart" onClicked: pieChart.parent = __subWindow.contentItem; } Button { id: changeValue text: "Change Value" onClicked: { var slice = pieSeries.find("eaten"); console.assert(slice !== null); if (slice !== null) { slice.value = 20; } } } } ChartView { id: pieChart width: 100 height: 100 theme: ChartView.ChartThemeBrownSand antialiasing: true legend.visible: false margins.top: 0 margins.left: 0 margins.bottom: 0 margins.right: 0 anchors.centerIn: parent PieSeries { id: pieSeries size: 1 onClicked: { pieSeries.find("notEaten").exploded = true; } PieSlice { label: "eaten"; value: 94.9 } PieSlice { label: "notEaten"; value: 5.1 } } } }