Hi,
I try to take window from QWorkspace. But it doesn't work:
Qt Code:
m_tablePanel = (TabelPanel *)(workspace->windowList()).at(0);To copy to clipboard, switch view to plain text mode
Thank you!
Hi,
I try to take window from QWorkspace. But it doesn't work:
Qt Code:
m_tablePanel = (TabelPanel *)(workspace->windowList()).at(0);To copy to clipboard, switch view to plain text mode
Thank you!
8Observer8 (22nd August 2013)
I cannot update my Plot.
42.jpg
I'm a little ashamed for my code. But this is my first MDI program.
There is a little code:
Qt 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*)));To copy to clipboard, switch view to plain text mode
Qt Code:
{ m_plotPanel->updatePanel(model); }To copy to clipboard, switch view to plain text mode
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?
8Observer8 (22nd August 2013)
I want to take instance of TablePanel and PlotPanel from workspace. I don't know how to do it.
It's doesn't work:
Qt Code:
m_tablePanel = qobject_cast<TabelPanel *>((workspace->windowList()).at(0)); m_plotPanel = qobject_cast<PlotPanel *>((workspace->windowList()).at(1));To copy to clipboard, switch view to plain text mode
I added the Table then the Plot.
Qt Code:
workspace->addWindow(tablePanel); workspace->addWindow(plotPanel);To copy to clipboard, switch view to plain text mode
Slot of MainWindow updatePanel() doesn't work.
Qt Code:
connect(m_tablePanel, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(updatePanel(QStandardItem*)));To copy to clipboard, switch view to plain text mode
Last edited by 8Observer8; 22nd August 2013 at 13:43.
8Observer8 (22nd August 2013)
I set a breakpoint in updatePanel() SLOT
Qt Code:
{ m_plotPanel->updatePanel(model); }To copy to clipboard, switch view to plain text mode
8Observer8 (22nd August 2013)
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.
8Observer8 (22nd August 2013)
Thanks! Now the breakpoint works.
Qt Code:
To copy to clipboard, switch view to plain text mode
But the Plot is not redrawn.
plotpanel.cpp
Qt 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(); }To copy to clipboard, switch view to plain text mode
8Observer8 (22nd August 2013)
Thanks! Thanks! Thanks!
There is an another problem. I wanna see the new plot. How to delete the old plot?
43.png
8Observer8 (22nd August 2013)
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.
8Observer8 (22nd August 2013)
How to get the old curve?
You can store it in some member variable and then retrieve it later when you need it.
8Observer8 (23rd August 2013)
Nice! It works! Thank you much
44.png
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
45.png<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>
Last edited by 8Observer8; 23rd August 2013 at 06:05.
Bookmarks