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

Enlazar dos ventanas



  • Good afternoon, how can I link several QDialog windows if I only have one QMainWindow, but I have already connected both qdialogs to the main one, so now I only need to run the QMainWindow (main cpp) without having to show it until I require it. Thank you.


  • Lifetime Qt Champion

    @Edward_SZS Sorry, I don't understand your description at all!
    "how can I link several QDialog windows" - what does "link" mean here?
    Can you please refrase your question and explain more clearly what you want to do?

    Also, please keep the caption of your thread in English.



  • @jsulm me refiero a como puedo pasar con un button box de una ventana (qdialog a otra qdialog). Gracias.



  • @jsulm Mi pregunta va en referencia a como hago para conectar dos ventanas que no son las principales, a su vez cree una principal para ejecutar la funciones de connect, pero quiero que en el main.cpp solo ejecute el qt application mas no lo muestre. Gracias.



  • @Edward_SZS Hola / Hello..

    Spanish:
    Debes conectar el botón con una función miembro en el constructor:

    English:
    You need to connect the current button with a member function of your current window, do it inside constructor:

    #include "mi_otra_ventana.h"
    
    mi_ventana::mi_ventana(){
         connect(ui->myButton, SIGNAL(clicked()), this, SLOT(onClick_myButton()));
    }
    
    //source, declaración función miembro
    void mi_ventana::onClick_myButton(){
         mi_otra_ventana w(this);
         int t = w.exec();
    
          if (t == QDialog::Accepted){
               //aquí va código en caso de que la ventana siguiente
               //se haya cerrado al hacer clic en Aceptar (si lo tiene)
           
                //here goes code in case you clicked accept
    
          }
    
    }
    
    
    //header
    private slots:
         void onClick_myButton();
    

  • Lifetime Qt Champion

    @Edward_SZS Please consider to use https://forum.qt.io/category/31/spanish if you want to ask in Spanish, this is English forum. I don't speak Spanish, so I can't help.


Log in to reply