Hi,
I try to take window from QWorkspace. But it doesn't work:
Code:
m_tablePanel = (TabelPanel *)(workspace->windowList()).at(0);
Thank you!
Printable View
Hi,
I try to take window from QWorkspace. But it doesn't work:
Code:
m_tablePanel = (TabelPanel *)(workspace->windowList()).at(0);
Thank you!
Please define what you mean by "it doesn't work".
I cannot update my Plot.
Attachment 9452
I'm a little ashamed for my code. But this is my first MDI program.
There is a little code:
Code:
m_tablePanel = (TabelPanel *)(workspace->windowList()).at(0); m_plotPanel = (PlotPanel *)(workspace->windowList()).at(1); connect(m_tablePanel, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(updatePanel(QStandardItem*)));
Maybe you can't update your plot but it doesn't mean the method doesn't work. Especially that you have an ugly C cast instead of qobject_cast or something similar. How do you know that the first item in the list is an instance of TablePanel and the second one is an instance of PlotPanel?
I want to take instance of TablePanel and PlotPanel from workspace. I don't know how to do it.
It's doesn't work:
Code:
m_tablePanel = qobject_cast<TabelPanel *>((workspace->windowList()).at(0)); m_plotPanel = qobject_cast<PlotPanel *>((workspace->windowList()).at(1));
I added the Table then the Plot.
Code:
workspace->addWindow(tablePanel); workspace->addWindow(plotPanel);
Slot of MainWindow updatePanel() doesn't work.
Code:
connect(m_tablePanel, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(updatePanel(QStandardItem*)));
I set a breakpoint in updatePanel() SLOT
You set a breakpoint and?
Apparently your signal-slot connection is invalid.
TablePanel class is unlikely to have a signal itemChanged() carrying a QStandardItem pointer unless you added such signal to the class yourself.
Thanks! Now the breakpoint works.
Code:
But the Plot is not redrawn.
plotpanel.cpp
Code:
#include "plotpanel.h" #include <QHBoxLayout> #include <QDebug> #include <qwt_plot_curve.h> #include <qwt_symbol.h> { mainLayout->addWidget(plot); this->setLayout(mainLayout); } { curve->setTitle(tr("Points")); curve->setSymbol(symbol); QPolygonF points; double x, y; for (int row = 0; row < model->rowCount(); row++) { x = model->data(index).toDouble(); index = model->index(row, 1); y = model->data(index).toDouble(); } curve->setSamples(points); curve->attach(plot); // this->update(); }
I don't see you calling replot() on the plot anywhere.
Thanks! Thanks! Thanks! :)
There is an another problem. I wanna see the new plot. How to delete the old plot?
Attachment 9458
Why not reuse the old curve instead?
Maybe I must delete the old curve? How to do it? I don't understand...
If you want to remove the old curve then detach it from the plot and delete it.
How to get the old curve?
You can store it in some member variable and then retrieve it later when you need it.
Nice! It works! Thank you much :)
Attachment 9459
This program is still left unfinished. But it may be useful for someone.
I made a loading (saving) table from (to) a xml-file:
Table.xml
Attachment 9461Quote:
<Table nrows="5" ncols="2">
<point x="0.02" y="0.33"/>
<point x="0.56" y="1.12"/>
<point x="2.22" y="2.33"/>
<point x="6.23" y="4.87"/>
<point x="9.55" y="8.23"/>
</Table>