<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">Alain,<div class=""><br class=""></div><div class="">The first method is sufficient. Be sure that you are calling the class’s superclass constructor or it will complain that the instance is “not a QMenu.” For example:</div><div class=""><br class=""></div><div class="">class MyMenu(QMenu):</div><div class="">    def __init__(self, parent=None):</div><div class="">        super().__init__(parent)</div><div class=""><br class=""></div><div class="">-Patrick</div><div class=""><br class=""><div><br class=""><blockquote type="cite" class=""><div class="">On Nov 17, 2017, at 10:53 AM, Alain Muls <<a href="mailto:alain.muls@gmail.com" class="">alain.muls@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class="">
  

    <meta http-equiv="content-type" content="text/html; charset=utf-8" class="">
  
  <div text="#000000" bgcolor="#FFFFFF" class=""><p class="">Hi All</p><p class="">I just started out with pyQt5 but I have experience with Qt and
      C++.</p><p class="">I try to separate my code in different files for not getting
      files that are too long. Therefor I am looking to a way that I can
      create the different QMenus (so 'file', 'edit', 'Help', etc) in
      separate files. I tried several things</p>
    <ul class="">
      <li class="">subclassing QMenu and then create in the main GUI part an
        instance that I add to the QMenuBar<br class="">
        <br class="">
      </li>
      <li class="">create a function in a different file that returns a QMenu
        that I add to the QMenuBar<br class="">
        <br class="">
      </li>
    </ul><p class="">but both methods didn't show the added menu in my menubar.</p><p class="">The first method had as problem that the derived class was not a
      QMenu, so could not be added.<br class="">
    </p><p class="">I tried second methods since in the documentation of QMenuBar I
      found:</p><p class=""><span style="font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">QAction<span class=""> </span></span><b style="font-variant-caps: normal; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class=""><a href="http://pyqt.sourceforge.net/Docs/PyQt4/qmenubar.html#addMenu" style="color: rgb(103, 41, 103); text-decoration: none;" class="">addMenu</a></b><span style="font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class=""><span class=""> </span>(</span><i style="font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">self</i><span style="font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">, QMenu </span><i style="font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255);" class="">menu</i><span style="font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">)</span></p>
    <span style="font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: rgb(255, 255, 255); float: none; display: inline !important;" class="">So it should be possible to add a QMenu
      (second method).<br class="">
    </span><p class="">Does someone has such an example?</p><p class="">Tx for your help</p><p class="">Alain<br class="">
    </p>
    <div class="moz-signature">-- <br class="">
      <br class="">
      <table style="background: none; border-width: 0px; border: 0px;
        margin: 0; padding: 0; border-collapse: collapse; border-top:
        1pt solid #F7751F; padding-top: 2px;" cellspacing="0" cellpadding="0" border="0" class="">
        <tbody class="">
          <tr class="">
            <td style="padding-top: 0; padding-bottom: 0; padding-left:
              0; padding-right: 7px; border-top: 0; border-bottom: 0:
              border-left: 0; border-right: solid 3px #F7751F" valign="top" class=""><span id="cid:part2.3D9DECBB.8372DBA7@gmail.com"><logorma-transparent-scaled.png></span></td>
            <td style="padding-top: 0; padding-bottom: 0; padding-left:
              12px; padding-right: 0;" class="">
              <table style="background: none; border-width: 0px; border:
                0px; margin: 0; padding: 0;" cellspacing="0" cellpadding="0" border="0" class="">
                <tbody class="">
                  <tr class="">
                    <td colspan="2" style="padding-bottom: 5px; color:
                      #F7751F; font-size: 14px; font-family: Arial,
                      Helvetica, sans-serif;" class=""><strong class="">Alain Muls</strong></td>
                  </tr>
                  <tr class="">
                    <td colspan="2" style="color: #333333; font-size:
                      11px; font-family: Arial, Helvetica, sans-serif;" class=""><i class="">Professor</i></td>
                  </tr>
                  <tr class="">
                    <td colspan="2" style="color: #333333; font-size:
                      11px; font-family: Arial, Helvetica, sans-serif;" class="">Department
                      CISS</td>
                  </tr>
                  <tr class="">
                    <td colspan="2" style="color: #333333; font-size:
                      11px; font-family: Arial, Helvetica, sans-serif;" class=""><strong class="">Royal
                        Military Academy</strong></td>
                  </tr>
                  <tr class="">
                    <td style="vertical-align: top; width: 20px; color:
                      #F7751F; font-size: 11px; font-family: Arial,
                      Helvetica, sans-serif;" valign="top" width="20" class="">p:</td>
                    <td style="vertical-align: top; color: #333333;
                      font-size: 11px; font-family: Arial, Helvetica,
                      sans-serif;" valign="top" class="">+32 244 13936</td>
                  </tr>
                  <tr class="">
                    <td style="vertical-align: top; width: 20px; color:
                      #F7751F; font-size: 11px; font-family: Arial,
                      Helvetica, sans-serif;" valign="top" width="20" class="">a:</td>
                    <td style="vertical-align: top; color: #333333;
                      font-size: 11px; font-family: Arial, Helvetica,
                      sans-serif;" valign="top" class="">Renaissance Avenue 30</td>
                  </tr>
                  <tr class="">
                    <td style="vertical-align: top; width: 20px; color:
                      #F7751F; font-size: 11px; font-family: Arial,
                      Helvetica, sans-serif;" valign="top" width="20" class=""> </td>
                    <td style="vertical-align: top; color: #333333;
                      font-size: 11px; font-family: Arial, Helvetica,
                      sans-serif;" valign="top" class="">B1000 Brussels (Belgium)</td>
                  </tr>
                  <tr class="">
                    <td style="vertical-align: top; width: 20px; color:
                      #F7751F; font-size: 11px; font-family: Arial,
                      Helvetica, sans-serif;" valign="top" width="20" class="">w:</td>
                    <td style="vertical-align: top; color: #333333;
                      font-size: 11px; font-family: Arial, Helvetica,
                      sans-serif;" valign="top" class=""><a href="http://www.rma.ac.be/ciss/en/" style="
                        color: #1da1db; text-decoration: none;
                        font-weight: normal; font-size: 11px;" class="">www.rma.ac.be/ciss/en/</a>  <span style="color: #F7751F;" class="">e: </span><a href="mailto:alain.muls@rma.ac.be" style="color:
                        #1da1db; text-decoration: none; font-weight:
                        normal; font-size: 11px;" class="">alain.muls@rma.ac.be</a></td>
                  </tr>
                </tbody>
              </table>
            </td>
          </tr>
        </tbody>
      </table>
    </div>
  </div>

_______________________________________________<br class="">PyQt mailing list    <a href="mailto:PyQt@riverbankcomputing.com" class="">PyQt@riverbankcomputing.com</a><br class=""><a href="https://www.riverbankcomputing.com/mailman/listinfo/pyqt" class="">https://www.riverbankcomputing.com/mailman/listinfo/pyqt</a></div></blockquote></div><br class=""></div></body></html>