Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

273
Visualizações
How to set QMainWindow as the modal one?

I am using QMainWindow for GUI development of my project..One problem I am Stuck with is blocking all other visible windows from getting input, while one is in operation.

I can not use QDialog.Because rich features of QMainWindow is required.

How can I declare a particular window as modal?

I tried with QWidget::setWindowMOdality().

Here is a demo program, what I tried but it didnt work.

#include <QApplication>
#include <QMainWindow>
#include <QPushButton>




int main(int argc, char **argv){


QApplication a(argc, argv);


    QMainWindow *w1 = new QMainWindow();
    w1->resize(500,800);
    w1->move(100,50);
    w1->show();


    QMainWindow *w2= new QMainWindow();
    w2->resize(800,500);
    w2->move(50,50);
    w2->show();

    w2->setWindowModality(Qt::ApplicationModal);


    return a.exec();

}
over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

Try setting the modal flag first, then show the widget.

w2->setWindowModality(Qt::ApplicationModal);
w2->show();

Also you could use QWidget and build the toolbar, menu bar and status bar.

over 4 years ago · Santiago Trujillo Relatório

1

Thanks for your answers, it helped me a lot with blocking the main window

In each of my forms I add that line of code to the constructor

 This->setWindowModality(Qt::ApplicationModal);
about 4 years ago · Daniel Ramos Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda