slot close widget shows an other empty dialog



  • Porting my Qt 4 application to Qt 5 on Mac OS 10.10, I'm encoutring a strange function. I'm creating a Widget from a mainWindow :

    if(workspace->subWindowList().contains((QMdiSubWindow *)frmHisto))
        {
            workspace->setActiveSubWindow(qobject_cast<QMdiSubWindow *>(frmHisto));
            return;
        }
    
        frmHisto = new frmListeOrdo(this);
        workspace->addSubWindow(frmHisto);/
    
        connect(frmHisto, SIGNAL(prescrire(int,int,Patient*,Abonne *)), this, SLOT(showPrescription(int,int,Patient*,Abonne *)));
        connect(frmHisto, SIGNAL(showMe()), this, SLOT(showHisto()));
    
        if(workspace->subWindowList().contains(qobject_cast<QMdiSubWindow *>(frOrdo)))
            connect(frOrdo, SIGNAL(changeOrdo()), frmHisto, SLOT(refreshOrdo()));
    
        frmHisto->show();
        frmHisto->setWindowState(Qt::WindowMaximized);
        
        workspace->setActiveSubWindow(qobject_cast<QMdiSubWindow *>(frmHisto));
        frmHisto->setFocus();
    

    In the frmHisto, I've a pushButton to close the Widget and I've added the closeEvent method

    connect(pbFermer, SIGNAL(clicked()), this, SLOT(fermer()));
    
    void frmListeOrdo::fermer()
    {
        close();
    }
    
    void frmListeOrdo::closeEvent(QCloseEvent *event)
    {
       event->accept();
    }
    

    but When I click the pushButton to close the Widget, I've an empty frmHisto Widget !

    This problem is not reproduced when I click the "X" close button of the Widget.

    Can tell me what's wrong and how to resolve this



  • This post is deleted!


  • does static_assert(std::is_base_of<QMdiSubWindow,frmListeOrdo>::value); complain?



  • Thanks for replying

    I'm encoutring to use static_assert(std::is_base_of<QMdiSubWindow,frmListeOrdo>::value); because of compilation errors

    I'll try again and return to you



  • @mourad_bilog said in slot close widget shows an other empty dialog:

    because of compilation errors

    Yes, compilation errors is what I'm looking for. If your compiler says that a static assertion failed it's what I wanted to know



  • And what I must to do to resolve the problem of closing ?

    Note that with the dialog button close ("X"), it works fine and it call the closeEvent method and emits event->accept.


  • Lifetime Qt Champion

    Hi,

    Out of curiosity, why are you re-implementing closeEvent just to accept the event ? There's no need for that if it's the only thing you do.



  • Thanks for reply.

    Well I'm testing solution I found after searching. You are wright, reimplenting closeEvent don't resolve the problem witch persists.

    What I've to modify to close the Widget when I click on the close button et not the Widget close ("X").

    close button calls the close() method.

    Thanks for your help



  • following this, the problem was resolved


Log in to reply
 

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