Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24

Thread: begginers question

  1. #21
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: begginers question

    Thanks for your post JD2000. I sort of understand but don't know how to implement it.... Are you sure you are a beginner?

  2. #22
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows
    Thanks
    21
    Thanked 418 Times in 411 Posts

    Default Re: begginers question

    Well there you have it, each call to addSpreadSheet() creates a new subwindow with
    Very good JD200, I totally missed that one.

    I sort of understand but don't know how to implement it....
    You can use a QVector to manage your subWindows.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #23
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: begginers question

    Thanks but I haven't a clue how to implement this.

  4. #24
    Join Date
    Feb 2010
    Posts
    53
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: begginers question

    Solved.
    Qt Code:
    1. MainWindowImpl::MainWindowImpl( QWidget * parent, Qt::WFlags f)
    2. : QMainWindow(parent, f)
    3. { // on constructor
    4. setupUi(this); // required so menues appear
    5.  
    6. mdiArea = new QMdiArea;
    7. mdiArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    8. mdiArea->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
    9. setCentralWidget(mdiArea);
    10. setWindowTitle(tr("Spreadsheet"))
    11.  
    12.  
    13. }
    14. void MainWindowImpl::createMdiWindow(const QString &fileName)
    15. {
    16. Spreadsheet *spreadsheet = new Spreadsheet;
    17. QMdiSubWindow *subWindow = mdiArea->addSubWindow(spreadsheet);
    18. subWindow->show();
    19. if (!fileName.isEmpty()) {
    20. // spreadsheet->load(fileName);
    21. statusBar()->showMessage(tr("File loaded"), 2000);
    22. }
    23. }
    24.  
    25. void MainWindowImpl::newFile()
    26. {
    27. createMdiWindow();
    28. }
    29.  
    30. Spreadsheet *MainWindowImpl::activeSpreadsheet()
    31. {
    32. QMdiSubWindow *subWindow = mdiArea->activeSubWindow();
    33. if (subWindow)
    34. return qobject_cast<Spreadsheet*>(subWindow->widget());
    35. return 0;
    36. }
    To copy to clipboard, switch view to plain text mode 

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.