<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">

    
	<channel>

	<title>Qt DevNet forums: C++ Gurus</title>
	<link>http://qt-project.org/forums/viewforum/36/</link>
	<description>RSS feed for latest threads in C++ Gurus</description>
	<copyright>Copyright 2012 Qt Developer Network</copyright>
	<docs>http://www.rssboard.org/rss-specification</docs>
	<generator>ExpressionEngine v2.3.1 http://expressionengine.com/</generator>
	<lastBuildDate>Tue, 04 Jan 2011 18:25:29 GMT</lastBuildDate>
	<atom:link href="http://qt-project.org/feeds/forum/36" rel="self" type="application/rss+xml" />

    

	
        <item>
            <title>namespace best practice</title>
            <link>http://qt-project.org/forums/viewthread/17472</link>
            <author>fluca1978</author>
            <description><![CDATA[Hi all,
I&#8217;m going to refactor a few classes in my project to belong all to the same namespace. Each class has its own header and implementation file. I&#8217;m just curious to know which is the best practice to contain all of them in a single namespace, do I have to create a &#8220;namespace&#8221; file like:

	namespace mySpace&#123;
&amp;nbsp; &amp;nbsp; class MyClassA;
&amp;nbsp; &amp;nbsp; class MyClassB;
&#125;


	or add the namespace block in each header file or what? Any suggestion is welcome.]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17472</guid>
            <pubDate>Thu, 24 May 2012 10:28:55 GMT</pubDate>
        </item>
	
        <item>
            <title>How do I compile my Qt Application for different systems?</title>
            <link>http://qt-project.org/forums/viewthread/17453</link>
            <author>maplesyrup23</author>
            <description><![CDATA[I&#8217;ve been using QExtSerialPort, and for some reason when I run and compile where I wrote the code (64 bit machine), it writes signals to the Arduino board. When I take the executable and its dependencies to another system, the signals are then not written to the Arduino board. 

	I suspect it may be because the app is compiled in a 64 bit machine and not in a 32 bit machine. Has this occured to any one of you guys? 

	Also, how do I compile it for a 32 bit computer? 

	Thank you in advance.]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17453</guid>
            <pubDate>Wed, 23 May 2012 16:38:31 GMT</pubDate>
        </item>
	
        <item>
            <title>Place to declare constants.</title>
            <link>http://qt-project.org/forums/viewthread/17220</link>
            <author>Mariø™</author>
            <description><![CDATA[Hello,

	My name is Mario, I&#8217;m new to this forum
and I sincerely apologize for my bad English.

	I am having a dilemma about which is the best place to declare constants.
For example, I have an item that is derived from QGraphicsItem,
this element has two constant colors: pen color and brush color.

	I&#8217;m thinking of declaring them as private constants:
class Rect : public QGraphicsItem
&#123;
&amp;nbsp;....
&amp;nbsp; &amp;nbsp; private:
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; static const int _penColor = 0;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; static const int _brushColor = 1;
&#125;;


	But it also can be declared as definitions in the header:
#define PENCOLOR 0
#define BRUSHCOLOR 1


	As well as local variables:
void Rect::draw&#40;&#41;
&#123;
&amp;nbsp; &amp;nbsp; const int penColor = 0;
&amp;nbsp; &amp;nbsp; const int brushColor = 1;
&#125;


	Maybe this is not important, but I wish I know what you think?

	Thanks, Mariø.]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17220</guid>
            <pubDate>Tue, 15 May 2012 00:08:32 GMT</pubDate>
        </item>
	
        <item>
            <title>Using Qt in Eclipse... without qmake?</title>
            <link>http://qt-project.org/forums/viewthread/17179</link>
            <author>Randomaniac</author>
            <description><![CDATA[Hi there,

	I&#8217;m new around here and decided to just keep lurking the forums until I&#8217;ve now encountered a problem I probably won&#8217;t be able to fix without any help. 

	I&#8217;m working on a C++ project in Eclipse (educational purposes) and decided to add some nice Qt GUI. This is achieved by using the Debug and Release options in Eclipse with the default g++ compiler. However, when using the Q_OBJECT macro I get &#8216;vtable&#8217; errors. After a long time of research I found that all these problems can be led back to qmake, as it apparently makes things a lot easier. However, I don&#8217;t have the luxury to use qmake in my project as it is not generally accepted in our team and have to be able to manage with just make.

	Is there any way I can integrate the Q_OBJECT macro in my project, using the default make? Even though I have the integrated Qt environment installed I code everything manually and don&#8217;t use it as to make it easier for my team to integrate it into their own Eclipse. 

	Any help or feedback would be greatly appreciated!

	Randomaniac]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17179</guid>
            <pubDate>Sun, 13 May 2012 13:37:27 GMT</pubDate>
        </item>
	
        <item>
            <title>[SOLVED] What mistake am I making when passing the signals to the Main Window slot?</title>
            <link>http://qt-project.org/forums/viewthread/17122</link>
            <author>maplesyrup23</author>
            <description><![CDATA[I have a class tCamera that is supposed to send signals to the Main Window. The qDebug statements show that the code is going where it is supposed to go, however, the application hangs, and I do not see the printer statements.

	NOTE: The mistake I was making was that I was giving control to another loop in a different source file, that never returned control to the main event loop. I fixed this by implementing threads (using QThread).]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17122</guid>
            <pubDate>Fri, 11 May 2012 02:18:04 GMT</pubDate>
        </item>
	
        <item>
            <title>[SOLVED] How would I go about accessing Ui from another function in a different source file?</title>
            <link>http://qt-project.org/forums/viewthread/17037</link>
            <author>maplesyrup23</author>
            <description><![CDATA[For example: in this chunk of code: 

	SOLVED by using simple Signals and Slots implementation. See below.]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17037</guid>
            <pubDate>Tue, 08 May 2012 20:03:56 GMT</pubDate>
        </item>
	
        <item>
            <title>char array to qint24 array</title>
            <link>http://qt-project.org/forums/viewthread/17016</link>
            <author>goocreations</author>
            <description><![CDATA[I&#8217;m doing music processing on 24bit samples. The raw samples are stored in a char array. I want to convert this array to a qint24 array.

	Now since there is no qint24 type, I decided to use qint32. A char has a size of 1 byte, so I will have to convert 3 chars to a 24bit sample at a time and store it in a qint32. This is what I&#8217;m currently doing:

	Code:

	char temp&#91;3&#93;;
int bufferCurrent;
for&#40;int i = 0; i &amp;lt; size; ++i&#41;
&#123;
&amp;nbsp;bufferCurrent = i * 3;
&amp;nbsp;temp&#91;0&#93; = buffer&#91;bufferCurrent&#93;;
&amp;nbsp;temp&#91;1&#93; = buffer&#91;bufferCurrent + 1&#93;;
&amp;nbsp;temp&#91;2&#93; = buffer&#91;bufferCurrent + 2&#93;;
&amp;nbsp;result&#91;i&#93; = reinterpret_cast&amp;lt;qint32&amp;gt;&#40;temp&#41;;
&#125;


	buffer is the char array and result my new array for the 24bit samples. g++ complaints that it can&#8217;t convert char* to qint32 (loses precision).

	So I basically need some way to convert 3 chars to a qint32. Any ideas of how to accomplish this?]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17016</guid>
            <pubDate>Tue, 08 May 2012 10:59:47 GMT</pubDate>
        </item>
	
        <item>
            <title>doubt about const member and containers</title>
            <link>http://qt-project.org/forums/viewthread/17010</link>
            <author>fluca1978</author>
            <description><![CDATA[Hi all,
I&#8217;ve got a doubt about the usage of const applied to a single class member like in the following:

	class Article&#123;
private:
&amp;nbsp; &amp;nbsp;const QString id;
&amp;nbsp; &amp;nbsp;QString&amp;amp; description;
&amp;nbsp;
public:
&amp;nbsp; &amp;nbsp;// methods
&#125;


	What I&#8217;d like to express is that the id of an article cannot be changed after the article has been changed. However to use articles with qt containers I have to provide a default constructor and an operator=, and my doubt is about how to implement them and which sense do they have (assigning an article to another does not make sense to me since the id is fixed). Can somebody explain me if this is wrong in design or not?]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/17010</guid>
            <pubDate>Tue, 08 May 2012 08:30:55 GMT</pubDate>
        </item>
	
        <item>
            <title>[SOLVED] Undefined Linker Error LNK1117: The compiler seems to toss out lines of my PRO file.</title>
            <link>http://qt-project.org/forums/viewthread/16999</link>
            <author>maplesyrup23</author>
            <description><![CDATA[I keep getting these error messages where the compiler appears to throw out the backslashes ending a bloc, and I&#8217;m unsure what I am doing wrong. Any input would be appreciated.

	If anyone else happens to stumble upon here while googling for the solution. It seems that my libraries have been included manually wrongly. Right&#45;clicking anywhere in the PRO file and selecting Add Library seems to fix this.]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/16999</guid>
            <pubDate>Mon, 07 May 2012 18:37:18 GMT</pubDate>
        </item>
	
        <item>
            <title>[SOLVED] QObject::QObject&apos; : cannot access private member declared in class &apos;QObject&apos; !</title>
            <link>http://qt-project.org/forums/viewthread/16974</link>
            <author>maplesyrup23</author>
            <description><![CDATA[Some of the functions in this class I defined uses some Qt children methods, so I had to have the Q_OBJECT macro. However, this is the sole error that comes up when I attempt to compile, and I neither know how to interpret it nor to fix it. Any input?

	&amp;nbsp;#ifndef HARDTRIGGER_H
#define HARDTRIGGER_H
&amp;nbsp;
#include 
#include &amp;lt;QObject&amp;gt;
&amp;nbsp;
class tCamera : public QObject
&#123;
&amp;nbsp; &amp;nbsp; Q_OBJECT
public:
&amp;nbsp; &amp;nbsp; unsigned long &amp;nbsp; UID;
&amp;nbsp; &amp;nbsp; tPvHandle &amp;nbsp; &amp;nbsp; &amp;nbsp; Handle;
&amp;nbsp; &amp;nbsp; tPvFrame &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Frame;
&amp;nbsp; &amp;nbsp; tPvUint32 &amp;nbsp; &amp;nbsp; &amp;nbsp; Counter;
&amp;nbsp; &amp;nbsp; char &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Filename&#91;20&#93;;
&amp;nbsp; &amp;nbsp; bool &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Abort;
private slots:
&amp;nbsp; &amp;nbsp; void WaitForCamera&#40;&#41;;
&amp;nbsp; &amp;nbsp; bool CameraGet&#40;&#41;;
&amp;nbsp; &amp;nbsp; bool CameraSetup&#40;&#41;;
&amp;nbsp; &amp;nbsp; void CameraUnsetup&#40;&#41;;
&amp;nbsp; &amp;nbsp; bool CameraStart&#40;&#41;;
&amp;nbsp; &amp;nbsp; void CameraStop&#40;&#41;;
&amp;nbsp; &amp;nbsp; bool CameraSnap&#40;&#41;;
&#125;;
#endif // HARDTRIGGER_H]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/16974</guid>
            <pubDate>Mon, 07 May 2012 04:21:16 GMT</pubDate>
        </item>
	
        <item>
            <title>Qt method swizzling</title>
            <link>http://qt-project.org/forums/viewthread/16964</link>
            <author>shav</author>
            <description><![CDATA[Hello guys,

	Now, I started a new project for testing some applications which development by Qt. My project is library which will integrating to any apps and the will saving special log with all information about status of work current app. I have experience in this &#8211; I was created library for iOS platform. On the iOS platform I have use the method swizzling from Objective&#45;C runtime. I want use something like this in Qt, but I can&#8217;t find any information about method swizzling in Qt/C++. Can you explaining how I can change implementation in Qt for methods from any classes of app?]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/16964</guid>
            <pubDate>Sun, 06 May 2012 08:23:37 GMT</pubDate>
        </item>
	
        <item>
            <title>Call to QLibrary resolved address works in Debug build, but not Release build</title>
            <link>http://qt-project.org/forums/viewthread/16868</link>
            <author>neveralull</author>
            <description><![CDATA[On a 64&#45;bit machine running Windows 7, a pointer to a function in a DLL is returned via QLibrary::resolve. A class member function is called via QtConcurrent::run, and inside that function it calls the function in the DLL. As long as I do a QtCreator Debug build, everything works perfectly fine. But when I do a Release build, after calling and getting a normal return from the DLL function when the calling function returns, instead of signalling finished() (which is what QtConcurrent::run normally does), it crashes. How can I even debug this, since it works just fine in the Debug build?]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/16868</guid>
            <pubDate>Thu, 03 May 2012 00:41:04 GMT</pubDate>
        </item>
	
        <item>
            <title>Global &quot;get&quot; functions through with Singleton, is it a good idea?</title>
            <link>http://qt-project.org/forums/viewthread/16867</link>
            <author>Danielc</author>
            <description><![CDATA[Hello everybody..

	I&#8217;m here again looking for some advices, so thank you before everything. 

	I have some collections in my main application class, but I need to retrieve them from other different classes and I would like to know a good way to achieve that. It looks like this:

	class Window : QMainWindow &#123;
&amp;nbsp; &amp;nbsp; // This class handles the collections and is responsible of setting up them
private:
&amp;nbsp; &amp;nbsp; DualCollection&amp;lt;Unit&amp;gt; units; //Internally implemented as two QHashes with QString as key type. Don&apos;t think it really matters.
&amp;nbsp; &amp;nbsp; DualCollection&amp;lt;GameItem&amp;gt; items;
&amp;nbsp; &amp;nbsp; // So on.
&#125;;
&amp;nbsp;
class RosterUnit &#123;
public:
&amp;nbsp; &amp;nbsp; void RosterUnit&#40;&#41;; // This method need to get a read&#45;only Unit and parse some information. It also needs access to some items
&#125;;
&amp;nbsp;
class ObjectAction &#123;
public:
&amp;nbsp; &amp;nbsp; void doAction&#40;&#41; = 0; // Some subclasses will eventually need access to some information like Units or Items
&#125;;


	In fact there are probably other two classes that need to retrieve some information.. I was thinking to use the Singleton pattern with the application class and provide functions like getItem(const QString&amp;amp; key), getUnit(&#8230;) and so on, but I&#8217;m not sure if it&#8217;s a good choice. I have read some disadvantages that apply to global variables and singletons like they are hard to debug because they can be modified in the whole application, but it does not apply here because I will provide only a public interface for reading.

	What do you think?

	Thank you very much!]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/16867</guid>
            <pubDate>Thu, 03 May 2012 00:33:48 GMT</pubDate>
        </item>
	
        <item>
            <title>Qt libs linking impact on speed of C++ code</title>
            <link>http://qt-project.org/forums/viewthread/16763</link>
            <author>herophuong</author>
            <description><![CDATA[Now my group is doing a small project assigned by our teacher. The task is to create a mini search engine in C/C++ which indexes text files and allows querying to search through them. 
What we concern now is the impact of Qt libs linking upon the speed of the C++ code part. We have over 2000 text files (about 134MB) to index. With CLI&#45;only version, the program takes nearly 80 seconds while in no&#45;GUI mode of GUI version, the program takes 200 seconds. We are keeping these two version on https://github.com/herophuong/Search&#45;engine [github.com]. &#8220;no&#45;GUI mode&#8221;&#8216;s code part of the GUI version is pure C++ and is exactly the same as CLI&#45;only version&#8217;s code. May some experts here can explain this for us. Thanks in advance.]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/16763</guid>
            <pubDate>Sun, 29 Apr 2012 17:36:47 GMT</pubDate>
        </item>
	
        <item>
            <title>How to avoid type comparision using polymorphism</title>
            <link>http://qt-project.org/forums/viewthread/16739</link>
            <author>Danielc</author>
            <description><![CDATA[Hi everybody!

	I&#8217;m facing a new problem while developing an application and I&#8217;d like to hear some advices regarding its design.

	I have a class (ObjectAction) which defines what should be done on specific situations. As I want to have different kinds of those &#8220;actions&#8221;, I was thinking to define ObjectAction like this:

	class ObjectAction &#123;
public:
&amp;nbsp; &amp;nbsp;virtual void perform&#40;...&#41; = 0;
&amp;nbsp; &amp;nbsp;virtual void writeToFile&#40;&#41; = 0:
&amp;nbsp; &amp;nbsp;virtual void readFromFile&#40;...&#41; = 0;
&#125;;


	So I can define its behavior by subclassing ObjectAction. For example:

	class ExampleAction : public ObjectAction &#123;
public:
&amp;nbsp; &amp;nbsp; &amp;nbsp;QString getData&#40;&#41; const &#123; return data; &#125;
&amp;nbsp; &amp;nbsp; &amp;nbsp;void setData&#40;const QString&amp;amp; newData&#41; &amp;nbsp;&#123; data = newData; &#125;
&amp;nbsp; &amp;nbsp; &amp;nbsp;void perform&#40;...&#41; &#123;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; qDebug&#40;&#41; &amp;lt;&amp;lt; data;
&amp;nbsp; &amp;nbsp; &amp;nbsp;&#125;
&amp;nbsp; &amp;nbsp; &amp;nbsp;// Other definitions missing
&amp;nbsp; &amp;nbsp; &amp;nbsp;.......
private:
&amp;nbsp; &amp;nbsp; QString data;
&#125;; 
&amp;nbsp;
class OtherAction : public ObjectAction &#123;
public:
&amp;nbsp; &amp;nbsp;......
&amp;nbsp; &amp;nbsp;void perform&#40;&#41; &#123; /*something else */ &#125;
&amp;nbsp; &amp;nbsp;.....
private:
&amp;nbsp; &amp;nbsp;QHash&amp;lt;QString, int&amp;gt; data;
&#125;;

It seems to be the good choice, but there is a problem: I want to provide an editor which allows user to set the ObjectAction to use, and he should be able to change the action kind and its data, so in my editor, if the action is of type ExampleAction, I will show a QLineEdit with the current data, but if the action is of type OtherAction, I should show some other widget to allow modifying the QHash. The same thing applies when I need to construct the action from data read from a file. The question is: How should I determine the type? Or better, how should I draw the editor for each type?

	Thank you very much!]]></description>
            <guid isPermaLink="false">http://qt-project.org/forums/viewthread/16739</guid>
            <pubDate>Sat, 28 Apr 2012 18:52:16 GMT</pubDate>
        </item>
	

	</channel>
</rss>
