<div dir="ltr">Hi Ludwig,<div><br></div><div>Thank you very much for your reply. You're right, QGIS stopped crashing, but now the button widget is not being carried out by the application window and neither the methods are working properly like the <span style="color:rgb(80,0,80)">self.setFixedSize(QSize(400,</span><span style="color:rgb(80,0,80)">300)). I am sending a window screenshot in attachment.</span></div><div><span style="color:rgb(80,0,80)"><br></span></div><div><span style="color:rgb(80,0,80)">I appreciated your time and help.</span></div><div><span style="color:rgb(80,0,80)"><br></span></div><div><span style="color:rgb(80,0,80)">Kind regards</span></div><div><span style="color:rgb(80,0,80)"><br></span></div><div><span style="color:rgb(80,0,80)">Julierme</span></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Aug 16, 2023 at 4:07 PM Ludwig Kniprath via QGIS-User <<a href="mailto:qgis-user@lists.osgeo.org">qgis-user@lists.osgeo.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div>
<p>Hi Julierme,</p>
<p>I think Your problem is, that You try to create a new application
with "app = QApplication(sys.argv)" inside a running QGis, which
already is a running Qt-application.</p>
<p>Simplified code should perform without crash:</p>
<p>import sys<br>
from PyQt5.QtCore import (QSize,Qt)<br>
from PyQt5.QtWidgets import (QApplication, QWidget, QPushButton,
QMainWindow)</p>
<p>class MainWindow(QMainWindow):<br>
   def _init_(self):<br>
       super()._init_()<br>
       self.setWindowTitle("My App")<br>
       button = QPushButton("Press Me!")<br>
<br>
      <br>
       self.setCentralWidget(button)<br>
       self.setFixedSize(QSize(400,300))<br>
<br>
window = MainWindow()<br>
window.show() <br>
</p>
<p><br>
</p>
<p>hth</p>
<p>Ludwig<br>
</p>
<div>Am 16.08.23 um 19:15 schrieb 1520 gis
via QGIS-User:<br>
</div>
<blockquote type="cite">
<div dir="ltr">Hi all,
<div><br>
</div>
<div>I wrote the PyQt script below and I am running it
through QGIS3. When I run it for the first time after opening
it in QGIS3, the application's window pops up smoothly.
However, when I close the window and run the script, QGIS3
readily quits. That may be something related to the event
loop, but I'm unsure and don't know how to stop the QGIS3
shutdown for the subsequent runs. Any hint on how to fix this
issue will be very appreciated. </div>
<div><br>
</div>
<div>import sys<br>
from PyQt5.QtCore import (QSize,<br>
             Qt)<br>
from PyQt5.QtWidgets import (QApplication,<br>
               QWidget,<br>
               QPushButton,<br>
               QMainWindow)<br>
</div>
<div>class MainWindow(QMainWindow):<br>
  def _init_(self):<br>
    super()._init_()<br>
    self.setWindowTitle("My App")<br>
    button = QPushButton("Press Me!")<br>
<br>
    <br>
    self.setCentralWidget(button)<br>
    self.setFixedSize(QSize(400,300))<br clear="all">
<div>app = QApplication(sys.argv)<br>
window = MainWindow()<br>
window.show()Â <br>
app.exec()<br>
</div>
<span class="gmail_signature_prefix">-- </span><br>
<div dir="ltr" class="gmail_signature">
<div dir="ltr">
<div><font face="verdana, sans-serif">##########################################</font></div>
<font size="4" face="verdana, sans-serif"><b><font color="#20124d">Julierme G Pinheiro</font></b><br>
<b><font color="#660000">SDI Expert & Geoprocessing
Specialist</font></b></font>
<div><font size="4" face="verdana, sans-serif"><font color="#351c75">Phone:</font>Â <font color="#444444">+55
61 99994-3569</font></font></div>
<div><font size="4" face="verdana, sans-serif"><font color="#351c75">Website:</font>Â <a href="https://www.udemy.com/course/qgis-server-para-iniciantes-instalacao-e-configuracao/" target="_blank">GIS</a></font></div>
</div>
</div>
</div>
</div>
<br>
<fieldset></fieldset>
<pre>_______________________________________________
QGIS-User mailing list
<a href="mailto:QGIS-User@lists.osgeo.org" target="_blank">QGIS-User@lists.osgeo.org</a>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a>
</pre>
</blockquote>
</div>
_______________________________________________<br>
QGIS-User mailing list<br>
<a href="mailto:QGIS-User@lists.osgeo.org" target="_blank">QGIS-User@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
Unsubscribe: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><font face="verdana, sans-serif">##########################################</font></div><font size="4" face="verdana, sans-serif"><b><font color="#20124d">Julierme G Pinheiro</font></b><br><b><font color="#660000">SDI Expert & Geoprocessing Specialist</font></b></font><div><font size="4" face="verdana, sans-serif"><font color="#351c75">Phone:</font>Â <font color="#444444">+55 61 99994-3569</font></font></div><div><font size="4" face="verdana, sans-serif"><font color="#351c75">Website:</font>Â <a href="https://www.udemy.com/course/qgis-server-para-iniciantes-instalacao-e-configuracao/" target="_blank">GIS</a></font></div></div></div>