How to set QPoint variable as a global variable?
Solved
Qt in Education
-
I want to set a
QPoint variable
as aglobal variable
such that it can be accessible and changeable from 3.cpp
source files.I tried creating a new
c++ class
namedglobals
as shown belowglobals.h
#ifndef GLOBALS_H #define GLOBALS_H //#include <QPoint> extern QPoint firstPoint , secondPoint; #endif // GLOBALS_H
globals.cpp
#include "globals.h" #include <QPoint> QPoint firstPoint = 0; //(0,0); QPoint secondPoint = 100; //(10,10);
if i include
#include<QPoint>
inglobals.h
this is the errorconversion from 'int' to non-scalar type 'QPoint' requested
if i do not include
#include<QPoint>
inglobals.h
error isQPoint does not name a type
Does anyone know whats wrong in this and how to add a global variable in any other method?
-
This may help:
Essentially, you don't want the definition to be defined as 'int' zero. Instead:
QPoint firstPoint = QPoint(0,0,);
Hope this helps.
-
@Carmoneer Thats the perfect solution
Thanks a lot... :)