Results 1 to 10 of 10

Thread: MDI [Windows XP]

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,376
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Thanks
    4
    Thanked 5,019 Times in 4,795 Posts
    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.


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

    Question Re: MDI [Windows XP]

    But, why in Linux is fine?

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

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

    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.

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

    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?

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

    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.

  6. 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.