Page 1 of 2 12 LastLast
Results 1 to 20 of 28

Thread: How to take window from QWorkspace?

  1. #1
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default How to take window from QWorkspace?

    Hi,

    I try to take window from QWorkspace. But it doesn't work:

    Qt Code:
    1. m_tablePanel = (TabelPanel *)(workspace->windowList()).at(0);
    To copy to clipboard, switch view to plain text mode 

    Thank you!

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    Please define what you mean by "it doesn't work".
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  4. #3
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    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:
    1. m_tablePanel = (TabelPanel *)(workspace->windowList()).at(0);
    2. m_plotPanel = (PlotPanel *)(workspace->windowList()).at(1);
    3.  
    4. connect(m_tablePanel, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(updatePanel(QStandardItem*)));
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void MainWindow::updatePanel(QStandardItem *item)
    2. {
    3. m_plotPanel->updatePanel(model);
    4. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    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?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  7. #5
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    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:
    1. m_tablePanel = qobject_cast<TabelPanel *>((workspace->windowList()).at(0));
    2. m_plotPanel = qobject_cast<PlotPanel *>((workspace->windowList()).at(1));
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by wysota View Post
    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 added the Table then the Plot.

    Qt Code:
    1. workspace->addWindow(tablePanel);
    2. workspace->addWindow(plotPanel);
    To copy to clipboard, switch view to plain text mode 

    Slot of MainWindow updatePanel() doesn't work.

    Qt Code:
    1. 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.

  8. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    Quote Originally Posted by 8Observer8 View Post
    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:
    1. m_tablePanel = qobject_cast<TabelPanel *>((workspace->windowList()).at(0));
    2. m_plotPanel = qobject_cast<PlotPanel *>((workspace->windowList()).at(1));
    To copy to clipboard, switch view to plain text mode 
    Define "doesn't work". Does the program crash or do you get a result different than what you expected to get?

    Slot of MainWindow updatePanel() doesn't work.
    The slot doesn't get called or it behaves differently to what you expected?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  10. #7
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    I set a breakpoint in updatePanel() SLOT

    Qt Code:
    1. void MainWindow::updatePanel(QStandardItem *item)
    2. {
    3. m_plotPanel->updatePanel(model);
    4. }
    To copy to clipboard, switch view to plain text mode 

  11. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    You set a breakpoint and?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  13. #9
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    Quote Originally Posted by wysota View Post
    You set a breakpoint and?
    Then I change value in the table. But nothing happens.

  14. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  15. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  16. #11
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    Thanks! Now the breakpoint works.

    Qt Code:
    1. connect(model, SIGNAL(itemChanged(QStandardItem *)), this, SLOT(updatePanel(QStandardItem*)));
    To copy to clipboard, switch view to plain text mode 

    But the Plot is not redrawn.

    plotpanel.cpp
    Qt Code:
    1. #include "plotpanel.h"
    2. #include <QHBoxLayout>
    3. #include <QDebug>
    4. #include <qwt_plot_curve.h>
    5. #include <qwt_symbol.h>
    6.  
    7. PlotPanel::PlotPanel(QWidget *parent) :
    8. QDialog(parent)
    9. {
    10. plot = new QwtPlot;
    11.  
    12. QHBoxLayout *mainLayout = new QHBoxLayout;
    13.  
    14. mainLayout->addWidget(plot);
    15.  
    16. this->setLayout(mainLayout);
    17. }
    18.  
    19. void PlotPanel::updatePanel(QStandardItemModel *model)
    20. {
    21. plot->setAxisScale(QwtPlot::yLeft, 0.0, 10);
    22. plot->setAxisScale(QwtPlot::xBottom, 0.0, 10);
    23.  
    24. QwtPlotCurve *curve = new QwtPlotCurve;
    25. curve->setTitle(tr("Points"));
    26. curve->setPen(QPen(Qt::blue, 4));
    27. curve->setRenderHint(QwtPlotItem::RenderAntialiased, true);
    28.  
    29. QwtSymbol *symbol = new QwtSymbol(QwtSymbol::Ellipse, QBrush(Qt::yellow),
    30. QPen(Qt::red, 2), QSize(8, 8));
    31. curve->setSymbol(symbol);
    32.  
    33. QPolygonF points;
    34.  
    35. double x, y;
    36. for (int row = 0; row < model->rowCount(); row++) {
    37. QModelIndex index = model->index(row, 0);
    38. x = model->data(index).toDouble();
    39.  
    40. index = model->index(row, 1);
    41. y = model->data(index).toDouble();
    42.  
    43. points << QPointF(x, y);
    44. }
    45.  
    46. curve->setSamples(points);
    47. curve->attach(plot);
    48.  
    49. // this->update();
    50. }
    To copy to clipboard, switch view to plain text mode 

  17. #12
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    I don't see you calling replot() on the plot anywhere.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  18. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  19. #13
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    Thanks! Thanks! Thanks!

    There is an another problem. I wanna see the new plot. How to delete the old plot?

    43.png

  20. #14
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    Why not reuse the old curve instead?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  21. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  22. #15
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    Maybe I must delete the old curve? How to do it? I don't understand...

  23. #16
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    If you want to remove the old curve then detach it from the plot and delete it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  24. The following user says thank you to wysota for this useful post:

    8Observer8 (22nd August 2013)

  25. #17
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    How to get the old curve?

  26. #18
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to take window from QWorkspace?

    You can store it in some member variable and then retrieve it later when you need it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  27. The following user says thank you to wysota for this useful post:

    8Observer8 (23rd August 2013)

  28. #19
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    Nice! It works! Thank you much

    44.png

    This program is still left unfinished. But it may be useful for someone.
    Attached Files Attached Files

  29. #20
    Join Date
    Nov 2012
    Posts
    232
    Thanks
    118
    Thanked 18 Times in 10 Posts
    Platforms
    Windows Android

    Default Re: How to take window from QWorkspace?

    I made a loading (saving) table from (to) a xml-file:

    Table.xml
    <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>
    45.png
    Attached Files Attached Files
    Last edited by 8Observer8; 23rd August 2013 at 06:05.

Similar Threads

  1. QWorkspace: child window layouts?
    By LiCodeX in forum Qt Programming
    Replies: 1
    Last Post: 13th November 2008, 07:50
  2. Removing window from QWorkspace
    By brcain in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2006, 20:25
  3. Qworkspace
    By weepdoo in forum Qt Tools
    Replies: 4
    Last Post: 24th July 2006, 10:37
  4. MDI windows without QWorkspace
    By Big Duck in forum Newbie
    Replies: 2
    Last Post: 16th June 2006, 17:15
  5. QWorkspace
    By fellobo in forum Qt Programming
    Replies: 4
    Last Post: 28th April 2006, 19:31

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.