Jump to content

[Qt Framework] Can include <QSystemInfo> , not recognized when creating instance

- - - - -

  • Please log in to reply
2 replies to this topic

#1
PunkDudez

PunkDudez

    Newbie

  • Members
  • PipPip
  • 10 posts
Hi

I am creating an Mobile Qt Application. I experience the next problem.
I can include <QSystemInfo> , this is recognized (because of the intelisense of Qt Creator 2.0).
When I want to make an instance of this class. I get error " 'QSystemInfo' not declard in this scope'". [on the red line code]


#include <QSystemInfo>


...


void MainWindow::readLocationInfo()

{

[COLOR="Red"]    QSystemInfo test();

    mCountry = test.currentCountryCode();[/COLOR]

    QString strOutput = "";

    strOutput +=

            "Country : " + infoSession.getCountry() + "\n" +

            "Language code : " + infoSession.getLanguageCode();

    QMessageBox::information(this, "Location Info", strOutput, tr("&OK"));

}

Also I edited my project file for this api

CONFIG += mobility

MOBILITY += systeminfo location


All other Qt classes are recognized (QString, ... )
Someone notices the my error ?

These version did not work out either

QSystemInfo test;

QSystemInfo *test = new QSystemInfo;


Edited by PunkDudez, 17 November 2010 - 02:30 PM.
Solved


#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,118 posts
  • Location:Vancouver, Eh! Cleverness: 200
This may be a silly mistake, but does this work?
QSystemInfo test;
mCountry = test.currentCountryCode();
You appear to be making the function "test()" into a struct, not creating a struct named test.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.

#3
PunkDudez

PunkDudez

    Newbie

  • Members
  • PipPip
  • 10 posts
Thanks for you reply. But it was not the cause of the problem.
Apparently almost each Tutorial failed to mention that the next code was also added to the class:
using namespace QtMobilityApi

Offcourse I couldn't instance an object because actually I needed to make an statement like:
QtMobilityApi::QSystemInfo info

Problem solved, worked on my nerves. Thanks for your time




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users