[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    Re: [PyQt] Resize flicking on QMainWindow centralWidget in python but not C++
From:       Patrick Stinson <patrickkidd () gmail ! com>
Date:       2019-10-10 13:35:26
Message-ID: 68A78BC4-487C-4455-BE24-1D8D0D7B51BF () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Looks like this is just a function of QQuickWidget, either in a layout or standalone:

    app = QApplication(sys.argv)
    mw = QWidget()
    w = QQuickWidget()
    Layout = QVBoxLayout(mw)
    Layout.addWidget(w)
    mw.show()
    app.exec()


    app = QApplication(sys.argv)
    mw = QQuickWidget()
    mw.show()
    app.exec()

> On Oct 10, 2019, at 9:29 AM, Patrick Stinson <patrickkidd@gmail.com> wrote:
> 
> Turns out simply adding a QQuickWidget as a child to QMainWindow::centralWidget \
> causes this problem. I imagine this is because of the OpenGL buffer in QtQuick: 
> app = QApplication(sys.argv)
> mw = QMainWindow()
> w = QQuickWidget()
> mw.setCentralWidget(w)
> mw.show()
> app.exec()
> 
> Does anyone know of a workaround for this? It makes the app look so ugly!
> 
> > On Oct 7, 2019, at 2:10 PM, Eric Pettersen <pett@cgl.ucsf.edu \
> > <mailto:pett@cgl.ucsf.edu>> wrote: 
> > We had this behavior in our own app, but it kind of went away on its own.  We \
> > came to suspect that it had to with the setting of MACOSX_DEPLOYMENT_TARGET.  I \
> > don't know if you set that variable in your compile, but if you do you might try \
> > changing it (or not setting it) and see what happens. 
> > —Eric
> > 
> > > On Oct 6, 2019, at 1:38 PM, Patrick Stinson <patrickkidd@gmail.com \
> > > <mailto:patrickkidd@gmail.com>> wrote: 
> > > I wonder if maybe the use of QQuickWidget child widgets enables some kind of \
> > > OpenGL buffer in the QMainWindoe? 
> > > > On Oct 6, 2019, at 12:25 AM, Patrick Stinson <patrickkidd@gmail.com \
> > > > <mailto:patrickkidd@gmail.com>> wrote: 
> > > > I put a qDebug() line in QMainWindow() and QOpenGLWidget(), \
> > > > rebuilt/installed Qt, and ran my app. I saw the line for the QMainWindow() \
> > > > but not QOpenGLWidget(), so that means QOpenGLWidget isn't being run in my \
> > > > app. But I am still seeing the problem. Difficult to pinpoint as a \
> > > > reproducible report. 
> > > > > On Oct 5, 2019, at 10:25 PM, Patrick Stinson <patrickkidd@gmail.com \
> > > > > <mailto:patrickkidd@gmail.com>> wrote: 
> > > > > So it does, and changing that makes it work like the C++ example.
> > > > > 
> > > > > My own app is still showing the problem even without using QOpenGLWidget. I \
> > > > > wonder if there is some setting somewhere that implicitly uses \
> > > > > QOpenGLWidget…. 
> > > > > > On Oct 5, 2019, at 5:36 PM, Eric Pettersen <pett@cgl.ucsf.edu \
> > > > > > <mailto:pett@cgl.ucsf.edu>> wrote: 
> > > > > > Your Python class inherits from QOpenGLWidget.  Your C++ class inherits \
> > > > > > from QWidget. 
> > > > > > > On Oct 5, 2019, at 2:10 PM, Patrick Stinson <patrickkidd@gmail.com \
> > > > > > > <mailto:patrickkidd@gmail.com>> wrote: 
> > > > > > > Hello,
> > > > > > > 
> > > > > > > On MacOS, a QMainWindow with a simple painted centralWidget flickers \
> > > > > > > when resizing quickly in python but not in C++. This only occurs with \
> > > > > > > QMainWindow It is particularly pronounced more complex widgets, as \
> > > > > > > shown in the following video: 
> > > > > > > https://youtu.be/0Qjy2wm6m9M <https://youtu.be/0Qjy2wm6m9M>
> > > > > > > 
> > > > > > > Here is the python example that shows the bug. Just run, rapidly resize \
> > > > > > > the height of the widget , and observe a black flickering on the top \
> > > > > > > edge of the widget as the height changes. 
> > > > > > > class Widget(QOpenGLWidget):
> > > > > > > def paintEvent(self, e):
> > > > > > > p = QPainter(self)
> > > > > > > p.setBrush(Qt.red)
> > > > > > > p.drawRect(self.rect())
> > > > > > > 
> > > > > > > app = QApplication(sys.argv)
> > > > > > > mw = QMainWindow()
> > > > > > > w = Widget()
> > > > > > > mw.setCentralWidget(w)
> > > > > > > mw.show()
> > > > > > > w.show()
> > > > > > > app.exec()
> > > > > > > 
> > > > > > > 
> > > > > > > The following 1-to-1 C++ translation shows no such behavior:
> > > > > > > 
> > > > > > > 
> > > > > > > #include <QApplication>
> > > > > > > #include <QMainWindow>
> > > > > > > #include <QWidget>
> > > > > > > #include <QPainter>
> > > > > > > 
> > > > > > > class Widget : public QWidget {
> > > > > > > public:
> > > > > > > void paintEvent(QPaintEvent *) {
> > > > > > > QPainter p(this);
> > > > > > > p.setBrush(Qt::red);
> > > > > > > p.drawRect(rect());
> > > > > > > }
> > > > > > > };
> > > > > > > 
> > > > > > > int main(int argc, char *argv[])
> > > > > > > {
> > > > > > > QApplication a(argc, argv);
> > > > > > > QMainWindow mw;
> > > > > > > QWidget *w = new Widget;
> > > > > > > mw.setCentralWidget(w);
> > > > > > > mw.show();
> > > > > > > return a.exec();
> > > > > > > }
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > 
> > > > > > > _______________________________________________
> > > > > > > PyQt mailing list    PyQt@riverbankcomputing.com \
> > > > > > > <mailto:PyQt@riverbankcomputing.com> \
> > > > > > > https://www.riverbankcomputing.com/mailman/listinfo/pyqt \
> > > > > > > <https://www.riverbankcomputing.com/mailman/listinfo/pyqt>
> > > > > > 
> > > > > 
> > > > 
> > > _______________________________________________
> > > PyQt mailing list    PyQt@riverbankcomputing.com \
> > > <mailto:PyQt@riverbankcomputing.com> \
> > > https://www.riverbankcomputing.com/mailman/listinfo/pyqt \
> > > <https://www.riverbankcomputing.com/mailman/listinfo/pyqt>
> > 
> 


[Attachment #5 (unknown)]

<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="">Looks like this is just a function of \
QQuickWidget, either in a layout or standalone:<div class=""><br class=""></div><div \
class=""><div style="margin: 0px; font-stretch: normal; line-height: normal; \
font-family: Monaco; color: rgb(218, 218, 218); background-color: rgb(0, 0, 0);" \
class=""><span style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; \
&nbsp;&nbsp;</span><span style="font-variant-ligatures: no-common-ligatures; color: \
#c1651c" class="">app</span><span style="font-variant-ligatures: no-common-ligatures" \
class=""> = QApplication(sys.argv)</span></div><div style="margin: 0px; font-stretch: \
normal; line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures; color: #c1651c" \
class="">mw</span><span style="font-variant-ligatures: no-common-ligatures" class=""> \
= QWidget()</span></div><div style="margin: 0px; font-stretch: normal; line-height: \
normal; font-family: Monaco; color: rgb(218, 218, 218); background-color: rgb(0, 0, \
0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: \
#f2f2f2" class="">&nbsp; &nbsp; </span><span style="font-variant-ligatures: \
no-common-ligatures; color: #c1651c" class="">w</span><span \
style="font-variant-ligatures: no-common-ligatures" class=""> = \
QQuickWidget()</span></div><div style="margin: 0px; font-stretch: normal; \
line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures; color: #f2f2f2" class="">&nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures; color: #c1651c" \
class="">Layout</span><span style="font-variant-ligatures: no-common-ligatures" \
class=""> =</span><span style="font-variant-ligatures: no-common-ligatures; color: \
#f2f2f2" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" \
class="">QVBoxLayout(mw)</span></div><div style="margin: 0px; font-stretch: normal; \
line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures; color: #f2f2f2" class="">&nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures" \
class="">Layout.addWidget(w)</span></div><div style="margin: 0px; font-stretch: \
normal; line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp; mw.show()</span></div><div style="margin: \
0px; font-stretch: normal; line-height: normal; font-family: Monaco; color: rgb(218, \
218, 218); background-color: rgb(0, 0, 0);" class=""><span \
style="font-variant-ligatures: no-common-ligatures; color: #f2f2f2" class="">&nbsp; \
&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" \
class="">app.</span><span style="font-variant-ligatures: no-common-ligatures; color: \
#c200ff" class="">exec</span><span style="font-variant-ligatures: \
no-common-ligatures" class="">()</span></div><div><br class=""></div><div><br \
class=""></div><div><div style="margin: 0px; font-stretch: normal; line-height: \
normal; font-family: Monaco; color: rgb(218, 218, 218); background-color: rgb(0, 0, \
0);" class=""><div style="margin: 0px; font-stretch: normal; line-height: normal;" \
class=""><span style="font-variant-ligatures: no-common-ligatures; color: #f2f2f2" \
class="">&nbsp; &nbsp;&nbsp;</span><span style="font-variant-ligatures: \
no-common-ligatures; color: #c1651c" class="">app</span><span \
style="font-variant-ligatures: no-common-ligatures" class=""> = \
QApplication(sys.argv)</span></div><div style="margin: 0px; font-stretch: normal; \
line-height: normal;" class=""><span style="font-variant-ligatures: \
no-common-ligatures; color: #f2f2f2" class="">&nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures; color: #c1651c" \
class="">mw</span><span style="font-variant-ligatures: no-common-ligatures" class=""> \
= QQuickWidget()</span></div><div style="margin: 0px; font-stretch: normal; \
line-height: normal;" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp; mw.show()</span></div><div style="margin: \
0px; font-stretch: normal; line-height: normal;" class=""><span \
style="font-variant-ligatures: no-common-ligatures; color: #f2f2f2" class="">&nbsp; \
&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" \
class="">app.</span><span style="font-variant-ligatures: no-common-ligatures; color: \
#c200ff" class="">exec</span><span style="font-variant-ligatures: \
no-common-ligatures" class="">()</span></div></div></div><div><br \
class=""><blockquote type="cite" class=""><div class="">On Oct 10, 2019, at 9:29 AM, \
Patrick Stinson &lt;<a href="mailto:patrickkidd@gmail.com" \
class="">patrickkidd@gmail.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" \
content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; line-break: after-white-space;" class="">Turns out simply \
adding a QQuickWidget as a child to QMainWindow::centralWidget causes this problem. I \
imagine this is because of the OpenGL buffer in QtQuick:<div class=""><br \
class=""></div><div class=""><div style="margin: 0px; font-stretch: normal; \
line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp;&nbsp;</span><span \
style="font-variant-ligatures: no-common-ligatures; color: #c1651c" \
class="">app</span><span style="font-variant-ligatures: no-common-ligatures" \
class=""> = QApplication(sys.argv)</span></div><div style="margin: 0px; font-stretch: \
normal; line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures; color: #c1651c" \
class="">mw</span><span style="font-variant-ligatures: no-common-ligatures" class=""> \
= QMainWindow()</span></div><div style="margin: 0px; font-stretch: normal; \
line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures; color: #f2f2f2" class="">&nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures; color: #c1651c" \
class="">w</span><span style="font-variant-ligatures: no-common-ligatures" class=""> \
= QQuickWidget()</span></div><div style="margin: 0px; font-stretch: normal; \
line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures; color: #f2f2f2" class="">&nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures" \
class="">mw.setCentralWidget(w)</span></div><div style="margin: 0px; font-stretch: \
normal; line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp; mw.show()</span></div><div style="margin: \
0px; font-stretch: normal; line-height: normal; font-family: Monaco; color: rgb(218, \
218, 218); background-color: rgb(0, 0, 0);" class=""><span \
style="font-variant-ligatures: no-common-ligatures; color: #f2f2f2" class="">&nbsp; \
&nbsp; </span><span style="font-variant-ligatures: no-common-ligatures" \
class="">app.</span><span style="font-variant-ligatures: no-common-ligatures; color: \
#c200ff" class="">exec</span><span style="font-variant-ligatures: \
no-common-ligatures" class="">()</span></div></div><div class=""><br \
class=""></div><div class="">Does anyone know of a workaround for this? It makes the \
app look so ugly!<br class=""><div class=""><div class=""><br class=""><blockquote \
type="cite" class=""><div class="">On Oct 7, 2019, at 2:10 PM, Eric Pettersen &lt;<a \
href="mailto:pett@cgl.ucsf.edu" class="">pett@cgl.ucsf.edu</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" \
content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; line-break: after-white-space;" class="">We had this \
behavior in our own app, but it kind of went away on its own. &nbsp;We came to \
suspect that it had to with the setting of MACOSX_DEPLOYMENT_TARGET. &nbsp;I don't \
know if you set that variable in your compile, but if you do you might try changing \
it (or not setting it) and see what happens.<div class=""><br class=""></div><div \
class="">—Eric<br class=""><div class=""><br class=""><blockquote type="cite" \
class=""><div class="">On Oct 6, 2019, at 1:38 PM, Patrick Stinson &lt;<a \
href="mailto:patrickkidd@gmail.com" class="">patrickkidd@gmail.com</a>&gt; \
wrote:</div><br class="Apple-interchange-newline"><div class=""><meta \
http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" \
class=""><div dir="ltr" class="">I wonder if maybe the use of QQuickWidget child \
widgets enables some kind of OpenGL buffer in the QMainWindoe?</div><div dir="ltr" \
class=""><br class=""><blockquote type="cite" class="">On Oct 6, 2019, at 12:25 AM, \
Patrick Stinson &lt;<a href="mailto:patrickkidd@gmail.com" \
class="">patrickkidd@gmail.com</a>&gt; wrote:<br class=""><br \
class=""></blockquote></div><blockquote type="cite" class=""><div dir="ltr" \
class=""><meta http-equiv="Content-Type" content="text/html; charset=utf-8" \
class="">I put a qDebug() line in QMainWindow() and QOpenGLWidget(), \
rebuilt/installed Qt, and ran my app. I saw the line for the QMainWindow() but not \
QOpenGLWidget(), so that means QOpenGLWidget isn't being run in my app. But I am \
still seeing the problem. Difficult to pinpoint as a reproducible report.<div \
class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On \
Oct 5, 2019, at 10:25 PM, Patrick Stinson &lt;<a href="mailto:patrickkidd@gmail.com" \
class="">patrickkidd@gmail.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" \
content="text/html; charset=utf-8" class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; line-break: after-white-space;" class="">So it does, and \
changing that makes it work like the C++ example.<div class=""><br \
class=""></div><div class="">My own app is still showing the problem even without \
using QOpenGLWidget. I wonder if there is some setting somewhere that implicitly uses \
QOpenGLWidget….<br class=""><div class=""><div class=""><br class=""><blockquote \
type="cite" class=""><div class="">On Oct 5, 2019, at 5:36 PM, Eric Pettersen &lt;<a \
href="mailto:pett@cgl.ucsf.edu" class="">pett@cgl.ucsf.edu</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" \
content="text/html; charset=us-ascii" class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; line-break: after-white-space;" class="">Your Python class \
inherits from QOpenGLWidget. &nbsp;Your C++ class inherits from QWidget.<br \
class=""><div class=""><br class=""><blockquote type="cite" class=""><div class="">On \
Oct 5, 2019, at 2:10 PM, Patrick Stinson &lt;<a href="mailto:patrickkidd@gmail.com" \
class="">patrickkidd@gmail.com</a>&gt; wrote:</div><br \
class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; \
-webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hello,<div \
class=""><br class=""></div><div class="">On MacOS, a QMainWindow with a simple \
painted centralWidget flickers when resizing quickly in python but not in C++. This \
only occurs with QMainWindow It is particularly pronounced more complex widgets, as \
shown in the following video:</div><div class=""><br class=""></div><div class=""><a \
href="https://youtu.be/0Qjy2wm6m9M" \
class="">https://youtu.be/0Qjy2wm6m9M</a></div><div class=""><br class=""></div><div \
class="">Here is the python example that shows the bug. Just run, rapidly resize the \
height of the widget , and observe a black flickering on the top edge of the widget \
as the height changes.</div><div class=""><br class=""></div><div class=""><div \
style="margin: 0px; font-stretch: normal; line-height: normal; font-family: Monaco; \
color: rgb(218, 218, 218); background-color: rgb(0, 0, 0);" class=""><font size="1" \
class=""><span style="font-variant-ligatures: no-common-ligatures; color: #c200ff" \
class="">class</span><span style="font-variant-ligatures: no-common-ligatures" \
class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: \
#2d961e" class="">Widget</span><span style="font-variant-ligatures: \
no-common-ligatures" class="">(QOpenGLWidget):</span></font></div><div style="margin: \
0px; font-stretch: normal; line-height: normal; font-family: Monaco; color: rgb(218, \
218, 218); background-color: rgb(0, 0, 0);" class=""><font size="1" class=""><span \
style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; \
</span><span style="font-variant-ligatures: no-common-ligatures; color: #c200ff" \
class="">def</span><span style="font-variant-ligatures: no-common-ligatures" \
class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: \
#6c6c1d" class="">paintEvent</span><span style="font-variant-ligatures: \
no-common-ligatures" class="">(</span><span style="font-variant-ligatures: \
no-common-ligatures; color: #c200ff" class="">self</span><span \
style="font-variant-ligatures: no-common-ligatures" class="">, \
e):</span></font></div><div style="margin: 0px; font-stretch: normal; line-height: \
normal; font-family: Monaco; color: rgb(218, 218, 218); background-color: rgb(0, 0, \
0);" class=""><font size="1" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; &nbsp; </span><span \
style="font-variant-ligatures: no-common-ligatures; color: #c1651c" \
class="">p</span><span style="font-variant-ligatures: no-common-ligatures" class=""> \
= QPainter(</span><span style="font-variant-ligatures: no-common-ligatures; color: \
#c200ff" class="">self</span><span style="font-variant-ligatures: \
no-common-ligatures" class="">)</span></font></div><div style="margin: 0px; \
font-stretch: normal; line-height: normal; font-family: Monaco; color: rgb(218, 218, \
218); background-color: rgb(0, 0, 0);" class=""><span style="font-variant-ligatures: \
no-common-ligatures" class=""><font size="1" class="">&nbsp; &nbsp; &nbsp; &nbsp; \
p.setBrush(Qt.red)</font></span></div><div style="margin: 0px; font-stretch: normal; \
line-height: normal; font-family: Monaco; color: rgb(218, 218, 218); \
background-color: rgb(0, 0, 0);" class=""><font size="1" class=""><span \
style="font-variant-ligatures: no-common-ligatures" class="">&nbsp; &nbsp; &nbsp; \
&nbsp; p.drawRect(</span><span style="font-variant-ligatures: no-common-ligatures; \
color: #c200ff" class="">self</span><span style="font-variant-ligatures: \
no-common-ligatures" class="">.rect())</span></font></div><div style="margin: 0px; \
font-stretch: normal; line-height: normal; font-family: Monaco; color: rgb(242, 242, \
<pre style="margin-top: 0px; margin-bottom: 0px;" class=""><!--StartFragment-->#<span \
style="color: rgb(0, 0, 128);" class="">include</span><span style="color: rgb(192, \
192, 192);" class=""> </span>&lt;<span style="color: rgb(0, 128, 0);" \
class="">QApplication</span>&gt;</pre> <pre style="margin-top: 0px; margin-bottom: \
0px;" class="">#<span style=" color:#000080;" class="">include</span><span style=" \
color:#c0c0c0;" class=""> </span>&lt;<span style=" color:#008000;" \
class="">QMainWindow</span>&gt;</pre> <pre style="margin-top: 0px; margin-bottom: \
0px;" class="">#<span style=" color:#000080;" class="">include</span><span style=" \
color:#c0c0c0;" class=""> </span>&lt;<span style=" color:#008000;" \
class="">QWidget</span>&gt;</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class="">#<span style=" color:#000080;" class="">include</span><span style=" \
color:#c0c0c0;" class=""> </span>&lt;<span style=" color:#008000;" \
class="">QPainter</span>&gt;</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class=""><br class=""></pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class=""><span style=" color:#808000;" class="">class</span><span style=" \
color:#c0c0c0;" class=""> </span><span style=" font-weight:600; color:#800080;" \
class="">Widget</span><span style=" color:#c0c0c0;" class=""> </span>:<span style=" \
color:#c0c0c0;" class=""> </span><span style=" color:#808000;" \
class="">public</span><span style=" color:#c0c0c0;" class=""> </span><span style=" \
color:#800080;" class="">QWidget</span><span style=" color:#c0c0c0;" class=""> \
</span>{</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span \
style=" color:#808000;" class="">public</span>:</pre> <pre style="margin-top: 0px; \
margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">    </span><span \
style=" color:#808000;" class="">void</span><span style=" color:#c0c0c0;" class=""> \
</span><span style=" font-weight:600; font-style:italic; color:#00677c;" \
class="">paintEvent</span>(<span style=" color:#800080;" \
class="">QPaintEvent</span><span style=" color:#c0c0c0;" class=""> </span>*)<span \
style=" color:#c0c0c0;" class=""> </span>{</pre> <pre style="margin-top: 0px; \
margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" class="">        \
</span><span style=" color:#800080;" class="">QPainter</span><span style=" \
color:#c0c0c0;" class=""> </span><span style=" color:#092e64;" \
class="">p</span>(<span style=" color:#808000;" class="">this</span>);</pre> <pre \
style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" \
class="">        </span><span style=" color:#092e64;" class="">p</span>.<span style=" \
color:#00677c;" class="">setBrush</span>(<span style=" color:#800080;" \
class="">Qt</span>::<span style=" color:#800080;" class="">red</span>);</pre> <pre \
style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" \
class="">        </span><span style=" color:#092e64;" class="">p</span>.<span style=" \
color:#00677c;" class="">drawRect</span>(<span style=" color:#00677c;" \
class="">rect</span>());</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class=""><span style=" color:#c0c0c0;" class="">    </span>}</pre> <pre \
style="margin-top: 0px; margin-bottom: 0px;" class="">};</pre> <pre \
style="margin-top: 0px; margin-bottom: 0px;" class=""><br class=""></pre> <pre \
style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#808000;" \
class="">int</span><span style=" color:#c0c0c0;" class=""> </span><span style=" \
font-weight:600; color:#00677c;" class="">main</span>(<span style=" color:#808000;" \
class="">int</span><span style=" color:#c0c0c0;" class=""> </span><span style=" \
color:#092e64;" class="">argc</span>,<span style=" color:#c0c0c0;" class=""> \
</span><span style=" color:#808000;" class="">char</span><span style=" \
color:#c0c0c0;" class=""> </span>*<span style=" color:#092e64;" \
class="">argv</span>[])</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class="">{</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" class=""><span \
style=" color:#c0c0c0;" class="">    </span><span style=" color:#800080;" \
class="">QApplication</span><span style=" color:#c0c0c0;" class=""> </span><span \
style=" color:#092e64;" class="">a</span>(<span style=" font-style:italic; \
color:#092e64;" class="">argc</span>,<span style=" color:#c0c0c0;" class=""> \
</span><span style=" color:#092e64;" class="">argv</span>);</pre> <pre \
style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" \
class="">    </span><span style=" color:#800080;" class="">QMainWindow</span><span \
style=" color:#c0c0c0;" class=""> </span><span style=" color:#092e64;" \
class="">mw</span>;</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" \
color:#800080;" class="">QWidget</span><span style=" color:#c0c0c0;" class=""> \
</span>*<span style=" color:#092e64;" class="">w</span><span style=" color:#c0c0c0;" \
class=""> </span>=<span style=" color:#c0c0c0;" class=""> </span><span style=" \
color:#808000;" class="">new</span><span style=" color:#c0c0c0;" class=""> \
</span><span style=" color:#800080;" class="">Widget</span>;</pre> <pre \
style="margin-top: 0px; margin-bottom: 0px;" class=""><span style=" color:#c0c0c0;" \
class="">    </span><span style=" color:#092e64;" class="">mw</span>.<span style=" \
color:#00677c;" class="">setCentralWidget</span>(<span style=" color:#092e64;" \
class="">w</span>);</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" \
color:#092e64;" class="">mw</span>.<span style=" color:#00677c;" \
class="">show</span>();</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class=""><span style=" color:#c0c0c0;" class="">    </span><span style=" \
color:#808000;" class="">return</span><span style=" color:#c0c0c0;" class=""> \
</span><span style=" color:#092e64;" class="">a</span>.<span style=" color:#00677c;" \
class="">exec</span>();</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" \
class="">}</pre> <pre style="margin-top: 0px; margin-bottom: 0px;" class=""><br \
class=""><!--EndFragment--></pre><div class=""><br class=""></div></div><div \
class=""><br class=""></div><div class=""><br class=""></div><div class=""><br \
class=""></div></div>_______________________________________________<br class="">PyQt \
mailing list &nbsp;&nbsp;&nbsp;<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><br \
class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br \
class=""></div></div></div></div></blockquote></div><br \
class=""></div></div></blockquote></div>_______________________________________________<br \
class="">PyQt mailing list &nbsp;&nbsp;&nbsp;<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><br \
class=""></div></blockquote></div><br \
class=""></div></div></div></blockquote></div><br \
class=""></div></div></div></div></blockquote></div><br class=""></div></body></html>


[Attachment #6 (text/plain)]

_______________________________________________
PyQt mailing list    PyQt@riverbankcomputing.com
https://www.riverbankcomputing.com/mailman/listinfo/pyqt


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic