[Qt-interest] [PyQT] Distinguish between designer and runtime code.
Emiliano Mennucci
ekumene at gmail.com
Tue Apr 21 14:22:28 CEST 2009
I have two processes which exange messages each other.
Process A is a normal (i.e non-qt) program which sends messages to process
B.
Process B is a QT GUI application showing received messages into a text box.
I created a customized widget (called ShowMessages) which inherits from
QPlainTextEdit and reads messages from a pipe when a timer expires, and
appends them in the text box.
Code is not really designed like this (which would be pretty bad design I
think), but it's just to make things simple here.
For reasons I won't tell, process A cannot be shut down while I'm creating
the form using qt-designer.
Problem is that while I'm using qt designer (thus selecting the ShowMessages
widget and putting it within the window) the widget begins to show messages,
even if I'm in the designer. This feature is cool but the problem is that
when I save the form, already present messages are saved in .ui file, which
results in turn in bad behaviour when I start process B (because process
starts showing messages I received during the creation phase).
I could clean the text box just after process B starts, but I think that
avoiding messages to be present in the .ui file is much better. What I want
is to be able to write code like this for the widget:
if <I'm not in the designer>
timer = QtCore.QTimer(self)
QtCore.QObject.connect(timer, QtCore.SIGNAL("timeout()"), self,
QtCore.SLOT("on_timer()"));
timer.start(2000)
Is there an qt function to know if I'm in the designer? Do you think that
distinguishing between designer and runtime code is "bad"?
(Sorry for mistakes, but English is not my primary language)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090421/eb77a1e8/attachment.html
More information about the Qt-interest-old
mailing list