PDA

View Full Version : Getting MAC Information from qt?



vishal.chauhan
23rd May 2007, 08:38
Hi All,

I m using Qt 4.1.5 on my Mac.
I want some system information as username currently using the system,Mac OS version, Machine Name,Processor Type(Intel or Power Pc) etc at run time.

If anybody knows how to get system information then plz help me.

Thanks.

marcel
23rd May 2007, 08:46
For CPU info use host_info() and the host_basic_info structure ( they are defined in host_info.h).

As for the others you have to use platform API.

Regards

vishal.chauhan
23rd May 2007, 09:00
Thanks for Reply.

Actually I m new to MAC so I donot know which API I have to use to get the other Information.

marcel
23rd May 2007, 09:02
Try looking on developer.apple.com.
But you can also look at darwinsource.opendarwin.org( which is down now :)).

patrik08
23rd May 2007, 09:31
Try looking on developer.apple.com.
But you can also look at darwinsource.opendarwin.org( which is down now :)).


I am not sure but now is all transfer to

http://www.macports.org/
http://www.macosforge.org/

libs && other i install from http://darwinports.com/

port install mysql ..

if you like to discovery sysinfo user..

I want some system information as username currently using the system,Mac OS version, Machine Name,Processor Type(Intel or Power Pc) etc at run time.

You can use applescript and qprocess...



#elif defined(Q_OS_MACX)

//create script
QString scriptFilename = ((Window*)qApp->mainWidget())->getTitle()->getAlbum()->getTmpDir() +
"/tmpBackgroundScript";

QFile file( scriptFilename );
if(file.open(IO_WriteOnly))
{
//-----
QTextStream stream;
stream.setDevice( &file );
stream.setEncoding( QTextStream::UnicodeUTF8 );
//-----
stream << "tell application \"Finder\"\n";
stream << "set pFile to POSIX file \"" << chosenFilename.ascii() << "\"\n";
stream << "set desktop picture to file pFile\n";
stream << "end tell";
}
file.close();

//run script to set background
QProcess p;
p.addArgument( "/usr/bin/osascript" );
p.addArgument( scriptFilename );
p.start();

//if there is an old file remove it
if(!oldFilename.isNull())
{ tmpDir.remove( oldFilename ); }

//-------------------------------
//UNIX
#else



have a look on applescript you can get so many info....