Results 1 to 9 of 9

Thread: subwindow mdi signal

  1. #1
    Join Date
    Jul 2007
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default subwindow mdi signal

    Hi.

    Im learning qmdiarea, but I have problem.
    What SIGNAL I need when I click buttom this do show new subwindow?

    Thz.

    Walter

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    Sorry Walter, but I don't understand your post.
    Do you have a button that shows a new MDI child? If you do, and your button is a QPushButton, then clicked() is the signal you're looking for.

    Otherwise please be more specific and maybe post some code.

    Regards

  3. #3
    Join Date
    Jul 2007
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    mainwindow.cpp

    Qt Code:
    1. mainWindow::mainWindow()
    2. {
    3. setupUi(this);
    4.  
    5. mdiArea = new QMdiArea;
    6. setCentralWidget(mdiArea);
    7. setWindowTitle(tr("MDI Editor"));
    8.  
    9. connect( menubar, SIGNAL(activated(int)), this, SLOT(actionNewWindow()) );
    10. }
    11.  
    12. void mainWindow::actionNewWindow()
    13. {
    14. QMdiSubWindow *subWindow1 = new QMdiSubWindow;
    15. subWindow1->setWindowTitle(tr("ZZZZ"));
    16. subWindow1->setAttribute(Qt::WA_DeleteOnClose);
    17. mdiArea->addSubWindow(subWindow1);
    18. }
    To copy to clipboard, switch view to plain text mode 


    I have this code, but I can do this SIGNAL? I have no error but no nothing to display.

    Well, Thz marcel!!

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    But you got it all wrong...
    The menu bar is just the container for window menus.
    These menus contain in turn menu items(actions).
    What you have to do is create a menu and add an action to it( called New Window, if you will).
    Then connect it's triggered signal to your slot.

    For a detailed example, see the Menus example( Main Windows section) in the Qt Demos.

    Regards

  5. #5
    Join Date
    Jul 2007
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    THz, I have read de source code for this example MENUS:

    Qt Code:
    1. connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
    To copy to clipboard, switch view to plain text mode 

    I changed this in my code, but nothing.

    Qt Code:
    1. connect(menubar, SIGNAL(triggered()), this, SLOT(actionNewWindow()));
    2.  
    3. or
    4.  
    5. connect(menuFile, SIGNAL(triggered()), this, SLOT(actionNewWindow()));
    To copy to clipboard, switch view to plain text mode 

    Any way, I not understand, but no problem.

    Thz

  6. #6
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    I think the only solution is to post the entire code and have someone look at it.

    Regards

  7. #7
    Join Date
    Jul 2007
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    Ok attach the project.

    Thz
    Attached Files Attached Files

  8. #8
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    Here's the corrected source:
    Qt Code:
    1. #include <QtGui>
    2. #include "mainwindow.h"
    3.  
    4. ventanaPrincipal::ventanaPrincipal()
    5. {
    6. setupUi(this);
    7.  
    8. mdiArea = new QMdiArea(this);
    9. setCentralWidget(mdiArea);
    10. setWindowTitle(tr("MDI Editor"));
    11. setMinimumSize(160, 160);
    12. resize(480, 320);
    13.  
    14. connect(actionNueva_ventana, SIGNAL(triggered()), this, SLOT(nueva_ventana()));
    15. }
    16.  
    17. void ventanaPrincipal::nueva_ventana()
    18. {
    19. QMdiSubWindow *subWindow1 = new QMdiSubWindow(this);
    20. subWindow1->setWindowTitle(tr("ZZZZ"));
    21. subWindow1->setAttribute(Qt::WA_DeleteOnClose);
    22. subWindow1->setWidget(new QPushButton("xxx"));
    23. mdiArea->addSubWindow(subWindow1);
    24. subWindow1->show();
    25. }
    To copy to clipboard, switch view to plain text mode 

    Your mistake is actually that you do not exactly know what it means to create menus with the designer.
    The designer adds a menu action for every menu item that you create. The action is named after the menu item.
    In your case, for the new window menu item you got the action actionNueva_ventana which was created automatically created for you.
    This happens with all menu items.

    I modified the slot name in order to make an explicit connect.

    Take a good look at ui_uimain.h( generated by UIC from your UI file). Try to make the (logical)connections between what is in there and what you created in the UI.

    Regards

  9. #9
    Join Date
    Jul 2007
    Posts
    24
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: subwindow mdi signal

    Thz for your help!!

    Now understand! In the Signal/Slot Editor (In designer) I created the connection:

    Qt Code:
    1. QObject::connect(actionNueva_ventana, SIGNAL(triggered()), vPrincipal, SLOT(actionNueva_ventana()));
    To copy to clipboard, switch view to plain text mode 

    Now work.
    Well thz, and attach project for future people need this example.

    Bye bye
    Attached Files Attached Files

Similar Threads

  1. how to emit signal in a static function ?
    By cxl2253 in forum Qt Programming
    Replies: 32
    Last Post: 7th July 2016, 21:36
  2. Replies: 3
    Last Post: 15th April 2007, 19:16
  3. Signal and slots
    By villy in forum Qt Programming
    Replies: 1
    Last Post: 12th January 2007, 10:10
  4. Replies: 2
    Last Post: 17th May 2006, 21:01
  5. no such signal QListBox::currentChanged()
    By jopie bakker in forum Newbie
    Replies: 2
    Last Post: 2nd March 2006, 15:17

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.