<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to write qDebug]]></title><description><![CDATA[<p dir="auto">the question is:<br />
*Using the function QObject::inherits(const char <em>className), write qDebug statements testing if o inherits QObject and ValueObject.</em>__<br />
my code is:<br />
widget.h<br />
@<br />
#ifndef WIDGET_H<br />
#define WIDGET_H</p>
<p dir="auto">#include&lt;QtGui&gt;<br />
#include &lt;QtGui/QWidget&gt;</p>
<p dir="auto">class Widget : public QWidget<br />
{<br />
Q_OBJECT<br />
Q_PROPERTY(int _value READ value WRITE setValue)<br />
public:<br />
Widget(int val =0, QWidget *parent = 0);<br />
void setValue(int val);<br />
int value();<br />
~Widget();<br />
private:<br />
QLabel *label;<br />
int _value;<br />
};</p>
<p dir="auto">#endif // WIDGET_H<br />
@<br />
widget.cpp<br />
@<br />
#include "widget.h"</p>
<p dir="auto">Widget::Widget(int val, QWidget *parent)<br />
: QWidget(parent)<br />
{<br />
setValue(val);<br />
label=new QLabel("I am liufan",this);</p>
<pre><code>QHBoxLayout *mainLayout=new QHBoxLayout(this);

mainLayout-&gt;addWidget(label);

this-&gt;setLayout(mainLayout);

this-&gt;setWindowTitle(tr("liufan"));
</code></pre>
<p dir="auto">}</p>
<p dir="auto">Widget::~Widget()<br />
{</p>
<p dir="auto">}</p>
<p dir="auto">void Widget::setValue(int val)<br />
{<br />
if(val == _value){<br />
return;<br />
}<br />
_value=val;<br />
}</p>
<p dir="auto">int Widget::value()<br />
{<br />
return _value;<br />
}</p>
<p dir="auto">@<br />
main.cpp<br />
@<br />
#include &lt;QtGui/QApplication&gt;<br />
#include "widget.h"</p>
<p dir="auto">int main(int argc, char *argv[])<br />
{<br />
QApplication a(argc, argv);<br />
Widget w;<br />
qDebug("Value: %d = %d", w.value(), w.property("_value").toInt());<br />
w.setValue(42);<br />
qDebug("Value: %d = %d", w.value(), w.property("_value").toInt());<br />
w.setProperty("value", 11);<br />
qDebug("Value: %d = %d", w.value(), w.property("_value").toInt());<br />
w.show();</p>
<pre><code>return a.exec&amp;#40;&amp;#41;;
</code></pre>
<p dir="auto">}<br />
@<br />
how do I to write the qDebug statements testing</p>
]]></description><link>https://forum.qt.io/topic/4786/how-to-write-qdebug</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Apr 2026 07:42:42 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/4786.rss" rel="self" type="application/rss+xml"/><pubDate>Fri, 01 Apr 2011 13:18:15 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 14:30:33 GMT]]></title><description><![CDATA[<p dir="auto">We all stumble over these tiny errors now and then :-)</p>
<p dir="auto">Feel free to ask further questions - we do not bite (mostly :-) )</p>
<p dir="auto">You might want to read <a href="http://www.catb.org/~esr/faqs/smart-questions.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://www.catb.org/~esr/faqs/smart-questions.html</a> some time, it has valuable hints on how to make a clever forum post.</p>
]]></description><link>https://forum.qt.io/post/82341</link><guid isPermaLink="true">https://forum.qt.io/post/82341</guid><dc:creator><![CDATA[goetz]]></dc:creator><pubDate>Fri, 01 Apr 2011 14:30:33 GMT</pubDate></item><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 14:23:44 GMT]]></title><description><![CDATA[<p dir="auto">thank you for your tips,I will be more careful to do it.<br />
I am a chinise undergraduate,I hope I can be a successful programmer.</p>
]]></description><link>https://forum.qt.io/post/82339</link><guid isPermaLink="true">https://forum.qt.io/post/82339</guid><dc:creator><![CDATA[liufanyansha]]></dc:creator><pubDate>Fri, 01 Apr 2011 14:23:44 GMT</pubDate></item><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 14:11:35 GMT]]></title><description><![CDATA[<p dir="auto">You made the simplest, yet very often most hardest to find error possible: Just a typo - you're missing the underscore before "value":</p>
<p dir="auto">@<br />
w.setProperty("value", 11); // wrong<br />
w.setProperty("_value", 11); // correct<br />
@</p>
]]></description><link>https://forum.qt.io/post/82336</link><guid isPermaLink="true">https://forum.qt.io/post/82336</guid><dc:creator><![CDATA[goetz]]></dc:creator><pubDate>Fri, 01 Apr 2011 14:11:35 GMT</pubDate></item><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 14:04:28 GMT]]></title><description><![CDATA[<p dir="auto">yes,It's that teaching me how to understand  the "Properties".because I am a beginer,so I'm not so clear what and how to do.thank you for helping me.</p>
<p dir="auto">when commenting out the<br />
@<br />
//Q_PROPERTY(int _value READ value WRITE setValue)<br />
@<br />
I got<br />
@<br />
E:\study\qt\project\lianxi1-build-desktop\release\lianxi1.exe 启动中...<br />
Value: 0 = 0<br />
Value: 42 = 0<br />
Value: 42 = 0<br />
E:\study\qt\project\lianxi1-build-desktop\release\lianxi1.exe 退出， 代码: 0<br />
@</p>
<p dir="auto">but<br />
@<br />
Q_PROPERTY(int _value READ value WRITE setValue)<br />
@</p>
<p dir="auto">I got<br />
@<br />
E:\study\qt\project\lianxi1-build-desktop\release\lianxi1.exe 启动中...<br />
Value: 0 = 0<br />
Value: 42 = 42<br />
Value: 42 = 42<br />
E:\study\qt\project\lianxi1-build-desktop\release\lianxi1.exe 退出， 代码: 0<br />
@</p>
<p dir="auto">thank you remind me that be careful to start a discussion</p>
]]></description><link>https://forum.qt.io/post/82334</link><guid isPermaLink="true">https://forum.qt.io/post/82334</guid><dc:creator><![CDATA[liufanyansha]]></dc:creator><pubDate>Fri, 01 Apr 2011 14:04:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 13:41:28 GMT]]></title><description><![CDATA[<p dir="auto">No problem with not so good English here, we're international, and not everybody speaks English well.</p>
<p dir="auto">Can you explain a bit more detailed, what your problem is/was? I suspect that output should be</p>
<p dir="auto">@<br />
0 = 0<br />
42 = 42<br />
11 = 11<br />
@</p>
<p dir="auto">But the last line reads 42 = 42. That's corrected by the fix I posted before.</p>
]]></description><link>https://forum.qt.io/post/82332</link><guid isPermaLink="true">https://forum.qt.io/post/82332</guid><dc:creator><![CDATA[goetz]]></dc:creator><pubDate>Fri, 01 Apr 2011 13:41:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 13:37:28 GMT]]></title><description><![CDATA[<p dir="auto">I am very <a href="http://sorry.my" target="_blank" rel="noopener noreferrer nofollow ugc">sorry.my</a> english is so poor.next I will be carefully to start a discussion</p>
]]></description><link>https://forum.qt.io/post/82331</link><guid isPermaLink="true">https://forum.qt.io/post/82331</guid><dc:creator><![CDATA[liufanyansha]]></dc:creator><pubDate>Fri, 01 Apr 2011 13:37:28 GMT</pubDate></item><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 13:28:01 GMT]]></title><description><![CDATA[<p dir="auto">First: It would be helpful and polite, if you would provide us with the information what's going wrong. It's quite unrespectful to just dump a bunch of code and have the folks here figure out themselves what's happening.</p>
<p dir="auto"><em>EDIT:</em><br />
And I forgot: Choose your topic carefully! "how to write qDebug" has absolutely nothing to do with your actual problem!</p>
<p dir="auto">Regarding your problem:</p>
<p dir="auto">try:</p>
<p dir="auto">@<br />
w.setProperty("_value", 11);<br />
@</p>
]]></description><link>https://forum.qt.io/post/82327</link><guid isPermaLink="true">https://forum.qt.io/post/82327</guid><dc:creator><![CDATA[goetz]]></dc:creator><pubDate>Fri, 01 Apr 2011 13:28:01 GMT</pubDate></item><item><title><![CDATA[Reply to How to write qDebug on Fri, 01 Apr 2011 13:25:21 GMT]]></title><description><![CDATA[<p dir="auto">see "qInstallMsgHandler":<a href="http://doc.qt.nokia.com/latest/qtglobal.html#qInstallMsgHandler" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.nokia.com/latest/qtglobal.html#qInstallMsgHandler</a></p>
]]></description><link>https://forum.qt.io/post/82325</link><guid isPermaLink="true">https://forum.qt.io/post/82325</guid><dc:creator><![CDATA[alexKI]]></dc:creator><pubDate>Fri, 01 Apr 2011 13:25:21 GMT</pubDate></item></channel></rss>