//功能:將控件停靠到指定窗口的合適位置
BOOL CQTGUINumKeyboard::moveTo(QWidget *inputObject)
{
if(inputObject == NULL) return FALSE;
QPoint pointGlobal(inputObject->mapToGlobal(QPoint(0,0)));//獲取控件的屏幕座標
int objHeight = inputObject->height();
int objWidth = inputObject->width();
qDebug()<<"objHeight"<<objHeight;
qDebug()<<"objWidth"<<objWidth;
int selfHeight = this->height();
int selfWidth = this->width();
int screenWidth = QApplication::desktop()->width();
int screenHeight = QApplication::desktop()->height();
int leftBottomPointX = pointGlobal.x();//移動到左下方座標
int leftBottomPointY = pointGlobal.y()+objHeight;
int leftBottomRectWidth = leftBottomPointX+selfWidth;
int leftBottomRectHeight = leftBottomPointY+selfHeight;
qDebug()<<"pointGlobal.x"<<pointGlobal.x();
qDebug()<<"pointGlobal.y"<<pointGlobal.y();
qDebug()<<"leftBottomPointX"<<leftBottomPointX;
qDebug()<<"leftBottomPointY"<<leftBottomPointY;
int leftTopPointX = pointGlobal.x();//移動到左上方座標
int leftTopPointY = pointGlobal.y()-selfHeight;
int leftTopRectWidth = leftTopPointX+selfWidth;
int leftTopRectHeight = leftTopPointY;
int rightTopPointX = pointGlobal.x()+objWidth-selfWidth;//移動到右上方座標
int rightTopPointY = pointGlobal.y()-selfHeight;
int rightTopRectWidth = rightTopPointX;
int rightTopRectHeight = rightTopPointY;
int rightBottomPointX = pointGlobal.x()+objWidth-selfWidth;//移動到右下方座標
int rightBottomPointY = pointGlobal.y()+objHeight;
int rightBottomRectWidth = rightBottomPointX;
int rightBottomRectHeight = rightBottomPointY+selfHeight;
if((leftBottomRectWidth<=screenWidth)&&(leftBottomRectHeight<=screenHeight))
this->move(leftBottomPointX,leftBottomPointY);
else if((leftTopRectWidth<=screenWidth)&&(leftTopRectHeight>=0))
this->move(leftTopPointX,leftTopPointY);
else if((rightTopRectWidth>=0)&&(rightTopRectHeight>=0))
this->move(rightTopPointX,rightTopPointY);
else if((rightBottomRectWidth>=0)&&(rightBottomRectHeight<=screenHeight))
this->move(rightBottomPointX,rightBottomPointY);
return TRUE;
}