Results 1 to 10 of 10

Thread: MDI [Windows XP]

  1. #1
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question MDI [Windows XP]

    First, sorry about my English

    If I have opened one dialog, and back to main menu for select another menu, my application crash.

    ASSERT: "!activationRecursionGuard" in file widgets\qmenu.cpp, line 961

    How fix it ?
    Btw, In Linux is fine.

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

    Default Re: MDI [Windows XP]

    Can you show the relevant code?
    ==========================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. #3
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: MDI [Windows XP]

    I'm use QWorkspace as central widget

    Qt Code:
    1. ws=new QWorkspace(this);
    2.  
    3. setCentralWidget(ws);
    To copy to clipboard, switch view to plain text mode 


    This my menu action
    Qt Code:
    1. void MainWindow::on_actionKelas_triggered()
    2. {
    3. FrmKelas form(this);
    4. ws->addWindow(&form);
    5. form.exec();
    6. }
    7.  
    8.  
    9. void MainWindow::on_actionAnggota_triggered()
    10. {
    11. FrmAnggota form(this);
    12. ws->addWindow(&form);
    13. form.exec();
    14. }
    To copy to clipboard, switch view to plain text mode 

    FrmKelas & FrmAnggota inherit QDialog

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

    Default Re: MDI [Windows XP]

    The problem (I guess) is that you are creating FrmKelas on the stack.
    At the same time you are adding it to the mdi area, but as soon as the slot() gets out of scope, your form gets destroyed, living a not legal pointer in the mdi area.

    Try allocating your forms on the heap (with 'new') , it should help.
    ==========================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.

  5. #5
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: MDI [Windows XP]

    Not work

    This is QMenu bugs (in WinXP) ? I tried open FrmKelas from menu and open FrmAnggota from toolbar. Everything is fine.

  6. #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: MDI [Windows XP]

    This is a bug in your code and not in QMenu. Focus on correcting your own code instead of chasing non existing bugs in Qt. Try to compose a minimal compilable example reproducing your problem or use a debugger to find out where exactly it crashes. The code you posted doesn't make much sense, by the way. You're starting a modal dialog which at the same time you'd like to be part of MDI. The two don't go together.
    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.


  7. #7
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: MDI [Windows XP]

    But, why in Linux is fine?

    And, I think, I can opened more dialog if use QAction on QToolbar.

  8. #8
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: MDI [Windows XP]

    Just because it works on one OS does not mean you did it right. You should rather try your application on as many operating systems as possible to find bugs that might also affect the other plattforms but not (yet) show up.

    I dont think that it makes any difference how to open a dialog, e.g. a QPushButton, a QAction or a QMenu.
    It's nice to be important but it's more important to be nice.

  9. #9
    Join Date
    May 2009
    Location
    Gorontalo
    Posts
    200
    Thanks
    20
    Thanked 5 Times in 5 Posts
    Qt products
    Platforms
    Unix/X11 Windows

    Question Re: MDI [Windows XP]

    Really ? well, this is my sample code

    mainwindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3.  
    4. #include <QMainWindow>
    5. #include <QToolBar>
    6. #include <QWorkspace>
    7. #include <QAction>
    8. #include <QMenuBar>
    9.  
    10. class MainWindow : public QMainWindow
    11. {
    12. Q_OBJECT
    13. public:
    14. MainWindow(QWidget *parent = 0);
    15.  
    16. private:
    17.  
    18. QToolBar *toolbar;
    19. QAction *toolbar0, *toolbar1;
    20.  
    21. QWorkspace * ws;
    22.  
    23. QMenuBar *mainmenu;
    24. QMenu *mn;
    25.  
    26. private slots:
    27. void bukakelas();
    28. void bukaanggota();
    29.  
    30. };
    31.  
    32. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 


    mainwindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QDialog>
    3.  
    4. class FrmKelas: public QDialog
    5. {
    6. public:
    7. FrmKelas(QWidget *parent=0):QDialog(parent) { setFixedSize(200, 300); }
    8.  
    9. };
    10.  
    11.  
    12. class FrmAnggota: public QDialog
    13. {
    14. public:
    15. FrmAnggota(QWidget *parent=0):QDialog(parent) { setFixedSize(400, 100); }
    16.  
    17. };
    18.  
    19.  
    20. MainWindow::MainWindow(QWidget *parent)
    21. :QMainWindow(parent)
    22. {
    23.  
    24. toolbar=addToolBar("Tahede");
    25. toolbar0=new QAction(QIcon(":/icon/0.png"), tr("Kelas"), this);
    26. connect( toolbar0, SIGNAL(triggered()), this, SLOT(bukakelas()) );
    27. toolbar1=new QAction(QIcon(":/icon/1.png"), tr("Anggota"), this);
    28. connect( toolbar1, SIGNAL(triggered()), this, SLOT(bukaanggota()) );
    29. toolbar->addAction(toolbar0);
    30. toolbar->addAction(toolbar1);
    31.  
    32. ws=new QWorkspace(this);
    33. setCentralWidget(ws);
    34.  
    35. mainmenu=new QMenuBar(this);
    36. setMenuBar(mainmenu);
    37.  
    38.  
    39. mn=new QMenu("Master");
    40. //mn->addAction("Kelas", this, SLOT(bukakelas()));
    41. //mn->addAction("Anggota", this, SLOT(bukaanggota()));
    42. mn->addAction(toolbar0);
    43. mn->addAction(toolbar1);
    44. mainmenu->addMenu(mn);
    45. }
    46.  
    47.  
    48. void MainWindow::bukakelas()
    49. {
    50. FrmKelas form(this);
    51. ws->addWindow(&form);
    52. form.exec();
    53. }
    54.  
    55. void MainWindow::bukaanggota()
    56. {
    57. FrmAnggota form(this);
    58. ws->addWindow(&form);
    59. form.exec();
    60. }
    To copy to clipboard, switch view to plain text mode 


    main.cpp
    Qt Code:
    1. #include <QtGui/QApplication>
    2. #include "mainwindow.h"
    3.  
    4. int main(int argc, char *argv[])
    5. {
    6. QApplication a(argc, argv);
    7. MainWindow w;
    8. w.show();
    9. return a.exec();
    10. }
    To copy to clipboard, switch view to plain text mode 


    Where I make a mistake?

  10. #10
    Join Date
    Jan 2006
    Location
    Frankfurt
    Posts
    500
    Thanks
    1
    Thanked 52 Times in 52 Posts
    Platforms
    MacOS X Unix/X11

    Default Re: MDI [Windows XP]

    When you call exec on a dialog, it will block the application as long as the dialog stays open. Use show instead and create the dialog on the heap instead of the stack.
    It's nice to be important but it's more important to be nice.

  11. The following user says thank you to axeljaeger for this useful post:

    wirasto (27th October 2009)

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.