Confused in MDI window basics, please help



  • I'm reading Foundation of qt development book, while reading fourth chapter, author tells the basics of MDI window by showing this example :

    @MdiWindow::MdiWindow( QWidget parent ) : QMainWindow( parent )
    {
    setWindowTitle( tr( "MDI" ) );
    QWorkspace
    workspace = new QWorkspace;
    setCentralWidget( workspace );
    connect( workspace, SIGNAL(windowActivated(QWidget )), this, SLOT(enableActions()));
    mapper = new QSignalMapper( this );
    connect( mapper, SIGNAL(mapped(QWidget
    )), workspace, SLOT(setActiveWindow(QWidget*)) ); //my problem is in this line
    createActions();
    createMenus();
    createToolbars();
    statusBar()->showMessage( tr("Done") );
    enableActions();
    }@

    His this para of explanation completely eluded me (is it me or others having problem understanding it too?) :

    bq. Next, a signal mapping object called QSignalMapper is created and connected. A signal mapper is used to tie the source of the signal to an argument of another signal. In this example, the action of the menu item corresponding to each window in the Window menu is tied to the actual document window. The actions are in turn connected to mapper. When the triggered signal is emitted by the action, the sending action has been associated with the QWidget* of the corresponding document window. This pointer is used as the argument in the mapped(QWidget*) signal emitted by the signal mapping object.

    My question : I still don't get what is signal mapper class and how it's used?. Can anyone please explain the above para with easy terms? also It's be awesome if you could please teach me about mapper class's basics with simple example? possibly with layman's term?

    I'm unable to follow up until I understand this above thing first . Thanks a lot , I really appreciate the help.


  • Moderators

    Though very useful with MDI, QSignalMapper is unrelated directly to the MDI Window stuff, so your thread title is a little misleading.

    Did you already look at the "QSignalMapper":/doc/qt-4.8/qsignalmapper.html documentation?



  • @mlong Can you tell when we have MDI window, do menu changes (though actions are disabled/enabled) e.g suppose for one particular document we have menu "File/close" and for other document we have "File/remaper" ?

    Thnks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.