Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. slot close widget shows an other empty dialog

slot close widget shows an other empty dialog

Scheduled Pinned Locked Moved Solved General and Desktop
9 Posts 3 Posters 1.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mourad_bilog
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • VRoninV Offline
      VRoninV Offline
      VRonin
      wrote on last edited by VRonin
      #2
      This post is deleted!
      1 Reply Last reply
      0
      • VRoninV Offline
        VRoninV Offline
        VRonin
        wrote on last edited by
        #3

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

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mourad_bilog
          wrote on last edited by VRonin
          #4

          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

          VRoninV 1 Reply Last reply
          0
          • M mourad_bilog

            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

            VRoninV Offline
            VRoninV Offline
            VRonin
            wrote on last edited by
            #5

            @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

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mourad_bilog
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                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.

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                1 Reply Last reply
                0
                • M Offline
                  M Offline
                  mourad_bilog
                  wrote on last edited by
                  #8

                  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

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    mourad_bilog
                    wrote on last edited by
                    #9

                    following this, the problem was resolved

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved