This is from a QMainWidget, and is currently sold on Ovi. Take out what you dont need:
Code:
void QtBallZ::mouseReleaseEvent ( QMouseEvent * event )
{
myMovingMouse=false;
if(((event->globalX()-4) / 11 + 1)>40 || ((event->globalY()-4) / 11 + 1)>32)
{//This is a status bar tap for exit
if(event->globalY()<50)
{
clearDS();
ApplicationPrefs::savePrefs();
exit(0);
return;
}
}
if(enginestate==STATE_GAME && !paused)
{
if(((event->globalX()-4) / 11 + 1)>40 || ((event->globalY()-4) / 11 + 1)>32)
{//This is a status bar tap
if(event->globalY()>280)
hor=!hor;
return;
}
if(wallparams.horizontala || wallparams.horizontalb || wallparams.verticala || wallparams.verticalb)
{
return;
}
wallparams.x=(event->globalX()-4) / 11 + 1;
wallparams.y=(event->globalY()-4) / 11 + 1;
if(walls[wallparams.x][wallparams.y]==0 && !paused)
{//Reduce overhead if user taps stupidly on an already 255 area
if(hor)
{
wallparams.horizontala=wallparams.horizontalb=true;
wallparams.active=true;
}
else
{
wallparams.verticala=wallparams.verticalb=true;
wallparams.active=true;
}
walls[wallparams.x][wallparams.y]=1;
}
}
else
{//Command handling
int i;
handleCommand:
//Protect button
{
/*if((pEvent->screenX <30) && (pEvent->screenY>130))
{
handled=false;
break;
}*/
}
for(i=0;i<10;i++)
{//Praise the QT for the weird factors
if(textparams[i].active && textparams[i].position.contains(event->globalX(),event->globalY()))
{
doMenu(textparams[i].tapid);
}
}
}
}
void QtBallZ::mouseMoveEvent ( QMouseEvent * event )
{
myMouseX=event->globalX();
myMouseY=event->globalY();
}
void QtBallZ::mousePressEvent ( QMouseEvent * event )
{
myMovingMouse=true;
myMouseX=event->globalX();
myMouseY=event->globalY();
}