Show table in qml view chart tab

master
Jos van den Oever 2017-08-31 22:28:37 +02:00
parent cb95cec1ba
commit 56856d081b
5 changed files with 76 additions and 32 deletions

View File

@ -13,7 +13,6 @@ Item {
titleText: "Date"
format: "MMM yyyy"
tickCount: 10
//alignment: Qt.AlignBottom
}
ValueAxis {
@ -29,7 +28,7 @@ Item {
}
VXYModelMapper {
model: timeSeries
model: demo.timeSeries
xColumn: 0
yColumn: 1
series: cpu

View File

@ -56,11 +56,11 @@ ApplicationWindow {
id: fibonacciInput
placeholderText: "Your number"
validator: IntValidator {bottom: 0; top: 100;}
Component.onCompleted: { text = fibonacci.input }
onTextChanged: { fibonacci.input = parseInt(text, 10) }
Component.onCompleted: { text = demo.fibonacci.input }
onTextChanged: { demo.fibonacci.input = parseInt(text, 10) }
}
Text {
text: "The Fibonacci number: " + fibonacci.result
text: "The Fibonacci number: " + demo.fibonacci.result
}
}
}
@ -68,7 +68,7 @@ ApplicationWindow {
title: "list"
TableView {
id: listView
model: fibonacciList
model: demo.fibonacciList
TableViewColumn {
role: "display"
title: "Row"
@ -171,31 +171,72 @@ ApplicationWindow {
Tab {
id: chartTab
title: "chart"
// Row {
// anchors.fill: parent
Text {
text: "YAYAYA"
anchors.left: parent.left
anchors.right: i.left
RowLayout {
anchors.fill: parent
Component {
id: editableDelegate
Item {
Text {
text: styleData.value
visible: !styleData.selected
}
Loader {
id: loaderEditor
anchors.fill: parent
Connections {
target: loaderEditor.item
onEditingFinished: {
console.log('hi ', styleData.row, styleData.role, loaderEditor.item.text);
console.log(demo.timeSeries.data(styleData.row));
}
}
sourceComponent: styleData.selected ? editor : null
}
Component {
id: editor
TextInput {
id: textInput
text: styleData.value
MouseArea {
anchors.fill: parent
hoverEnabled: true
onClicked: textInput.forceActiveFocus()
}
}
}
}
}
TableView {
model: demo.timeSeries
Layout.fillHeight: true
TableViewColumn {
role: "input"
title: "input"
}
TableViewColumn {
role: "result"
title: "result"
}
itemDelegate: {
return editableDelegate;
}
}
Item {
id: i
anchors.right: parent.right
Layout.fillWidth: true
Layout.fillHeight: true
Text {
anchors.centerIn: parent
text: "QtChart is not available.";
visible: chartLoader.status !== Loader.Ready
}
Loader {
width: 100
anchors.fill: parent
id: chartLoader
// anchors.fill: parent
source: "chart.qml"
}
}
// }
}
}
}
}

View File

@ -25,11 +25,11 @@ private:
TimeSeries* const m_timeSeries;
Private * m_d;
bool m_ownsPrivate;
Q_PROPERTY(Fibonacci* fibonacci READ fibonacci FINAL)
Q_PROPERTY(FibonacciList* fibonacciList READ fibonacciList FINAL)
Q_PROPERTY(FileSystemTree* fileSystemTree READ fileSystemTree FINAL)
Q_PROPERTY(Processes* processes READ processes FINAL)
Q_PROPERTY(TimeSeries* timeSeries READ timeSeries FINAL)
Q_PROPERTY(Fibonacci* fibonacci READ fibonacci NOTIFY fibonacciChanged FINAL)
Q_PROPERTY(FibonacciList* fibonacciList READ fibonacciList NOTIFY fibonacciListChanged FINAL)
Q_PROPERTY(FileSystemTree* fileSystemTree READ fileSystemTree NOTIFY fileSystemTreeChanged FINAL)
Q_PROPERTY(Processes* processes READ processes NOTIFY processesChanged FINAL)
Q_PROPERTY(TimeSeries* timeSeries READ timeSeries NOTIFY timeSeriesChanged FINAL)
explicit Demo(bool owned, QObject *parent);
public:
explicit Demo(QObject *parent = nullptr);
@ -45,6 +45,11 @@ public:
const TimeSeries* timeSeries() const;
TimeSeries* timeSeries();
signals:
void fibonacciChanged();
void fibonacciListChanged();
void fileSystemTreeChanged();
void processesChanged();
void timeSeriesChanged();
};
class Fibonacci : public QObject

View File

@ -365,11 +365,10 @@ private:
)";
for (auto p: o.properties) {
bool obj = p.type.type == BindingType::Object;
h << QString(" Q_PROPERTY(%1 %2 READ %2 %3%4FINAL)")
h << QString(" Q_PROPERTY(%1 %2 READ %2 %3NOTIFY %2Changed FINAL)")
.arg(p.type.name + (obj ?"*" :""),
p.name,
p.write ? writeProperty(p.name) :"",
obj ?"" :("NOTIFY " +p.name + "Changed "))
p.write ? writeProperty(p.name) :"")
<< endl;
}
h << QString(R"( explicit %1(bool owned, QObject *parent);
@ -393,9 +392,7 @@ public:
}
h << "signals:" << endl;
for (auto p: o.properties) {
if (p.type.type != BindingType::Object) {
h << " void " << p.name << "Changed();" << endl;
}
h << " void " << p.name << "Changed();" << endl;
}
h << "};" << endl;
}

View File

@ -19,7 +19,7 @@ private:
Person* const m_person;
Private * m_d;
bool m_ownsPrivate;
Q_PROPERTY(Person* person READ person FINAL)
Q_PROPERTY(Person* person READ person NOTIFY personChanged FINAL)
explicit Group(bool owned, QObject *parent);
public:
explicit Group(QObject *parent = nullptr);
@ -27,6 +27,7 @@ public:
const Person* person() const;
Person* person();
signals:
void personChanged();
};
class InnerObject : public QObject
@ -60,7 +61,7 @@ private:
InnerObject* const m_object;
Private * m_d;
bool m_ownsPrivate;
Q_PROPERTY(InnerObject* object READ object FINAL)
Q_PROPERTY(InnerObject* object READ object NOTIFY objectChanged FINAL)
explicit Person(bool owned, QObject *parent);
public:
explicit Person(QObject *parent = nullptr);
@ -68,5 +69,6 @@ public:
const InnerObject* object() const;
InnerObject* object();
signals:
void objectChanged();
};
#endif // TEST_OBJECTS_RUST_H