Adding items to a list
-
In the compiler output window there should be information about where the compiler thinks that procList has been declared (something like "previously declared here: " )
-
c:\QtSDK\Desktop\Qt\4.7.3\mingw\include\QtCore\qatomic_i386.h:125: error: first defined here
-
Hmm... try to use
@ inline operator QString() const
{
return QString::number(ID);
}
@ -
Same error :( The error is on procList anyways not ProcInfo, it doesn't make alot of sense to me :/
-
If you wish procList in header, you need to declare it in cpp file, and define in header as
@extern std::list< ProcInfo > procList@ -
Guys. It's not a "try and guess" process. He defined a global variable inside a header. As soon as that header gets included in two or more translation units, the compiler will output multiple definitions of the same name. And the linker will complain. Put that definition in ONE translation unit and you'll be ok.
-
Works thanks :) But now I have other unrelated questions, should I post in a separate thread?
-
Yep, You do. One theme - one thread.
-
I have another question about this.
The function currently working is:
@
class ProcInfo
{
public:
HANDLE Proc;
DWORD Base;
std::string WindowName;
int ID;
inline operator QString() const
{
return QString::number(ID);
}
};
@How would I mane the QString method return the following format:
"(" + ID + ") " + WindowName
So the output would end up something like:
(432) NotePad
-
@
return QString('(') + QString::number(ID) + ')' + WindowName.c_str()
@
Also have a look at "More Efficient String Construction":http://doc.qt.nokia.com/latest/qstring.html#more-efficient-string-construction