Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

How to enable menu options to all Qmdisubwindow?



  • Hi,
    I have created GUI which render 3d model and view wireframe,point etc view of the rendered model. I have used Qtmdi so that I can open multiple document. Now my problem is , if I open the only one window I am able to perform view (menubar option is view)option(wireframe,point,etc..). but If i open multiple window say window1,window2,window3 etc.. , if i click view option , the window which I opened recently say window3 , I am able to perform view operation but not for other windows . How to enable menu options to all window so that I can perform view operation in all window if I select that window??


  • Lifetime Qt Champion

    Hi
    Without code or pictures Im not sure what is wrong with the option menu.
    Normally, the slot for the Option Action could use
    http://doc.qt.io/qt-5/qmdiarea.html#activeSubWindow
    To operated on the "Selected" one.



  • Hai,

    I have created menu option using qt creator not using code. here is my subwindow code.

    QMdiSubWindow *subW = ui.mdiArea->addSubWindow(qwidget);
    subW->setWindowFlags(Qt::SubWindow);
    subW->setAttribute(Qt::WA_DeleteOnClose);
    subW->setObjectName(model_path);
    subW->setWindowTitle(model_path);
    subW->maximumSize();
    subW->show();
    ui.mdiArea->setActiveSubWindow(subW);
    ui.statusBar->showMessage("Loaded " + model_path, 5000);

  • Lifetime Qt Champion

    That look fine but its still not clear what is wrong with your optionmenu ?
    Can you show the slot/code that happens when you click an option?



  • Hi ,
    yeah sure..

      connect(ui.action3D_Model, SIGNAL(triggered()), this, SLOT(loadViewer_3d()));
        connect(ui.actionWireFrame, SIGNAL(triggered()), this, SLOT(wireframed_model()));
      connect(ui.actionPoint, SIGNAL(triggered()), this, SLOT(point_model()));
      connect(ui.actionFill, SIGNAL(triggered()), this, SLOT(filled_model()));	
    

    loadViewer_3d() code

    
      model_path = QFileDialog::getOpenFileName(this, tr("Open 3D Model"), "", tr("ALL(*.obj *.dxf *.ply *.3ds *.osg *.osgb *.osgt);;3D Studio(*.3ds);;OBJ(*.obj);;DXF(*.dxf);;PLY(*.ply);;OpenSceneGraph(*.osg *.osgb *.osgt)"));
    	QByteArray file = model_path.toLatin1();
    	char *input = file.data();
    	if (!model_path.isEmpty())
    	{
    		ui.statusBar->showMessage("Loading... " + model_path);
    		osgViewer::ViewerBase::ThreadingModel threadingModel = osgViewer::ViewerBase::SingleThreaded;
    		viewWidget = new ModelRender(input, 0, Qt::Widget, threadingModel);	
    		viewWidget->setGeometry(100, 100, 1024, 2048);		
    		loadModelWidget(viewWidget);
    	}
    	else
    	{
    		QMessageBox::information(this, "Alert", "3D Model is Missing");
    	}
    

    loadModelWidget -- code

      QMdiSubWindow *subW = ui.mdiArea->addSubWindow(qwidget);
    subW->setWindowFlags(Qt::SubWindow);
    subW->setAttribute(Qt::WA_DeleteOnClose);
    subW->setObjectName(model_path);
    subW->setWindowTitle(model_path);
    subW->maximumSize();
    subW->show();
    ui.mdiArea->setActiveSubWindow(subW);
    ui.statusBar->showMessage("Loaded " + model_path, 5000);
    

  • Lifetime Qt Champion

    Ok
    So if you dont use activeSubWindow() to perform view operations on , you can use
    http://doc.qt.io/qt-5/qmdiarea.html#subWindowList
    to get list of all open windows and do it this way?



  • okay I will try with subwindowlist


  • Lifetime Qt Champion

    @umadevi

    Do I understand it correctly that you want the View setting to apply to all open?
    So If you choose vireframe all windows go wireframe?


Log in to reply