qt 實現控件的模擬人類習慣的上下左右控制
{
QString Name=Ctrl->metaObject()->className();
if(Name.compare("QWidget")==0)
{
QObjectList childlist=Ctrl->children();
if(childlist.count()>0)
{
foreach (QObject *childobj, childlist)
{
PushINListRight(ControlList,childobj,CurrentCtrl);
}
}
}
else if(Name.compare("QLineEdit")==0||Name.compare("QPushButton")==0||Name.compare("QComboBox")==0||Name.compare("QDoubleSpinBox")==0)
{
if(((QWidget*)Ctrl)->isEnabled()==true&&((QWidget*)Ctrl)->isVisible()==true){
int x=Get_MainPos(Ctrl).x();
int y=Get_MainPos(Ctrl).y();
int Height=Get_MainPos(Ctrl).x()-Get_MainPos(CurrentCtrl).x();
if(Height>0)
{
ControlList->append(Ctrl);
}
}
}
else if(Name.compare("QVBoxLayout")==0)
{
QObjectList childlist2=Ctrl->children();
if(childlist2.count()>0)
{
foreach (QObject *childobj2, childlist2)
{
PushINListRight(ControlList,childobj2,Ctrl);
}
}
}
}
{
QString Parents=((QWidget*)Ctrl)->parent()->metaObject()->className();
if(Parents.compare("cy_main")==0)
{
return ((QWidget*)Ctrl)->pos();
}
else
{
QWidget *temp=((QWidget*)Ctrl)->parentWidget();
QString ParentName=temp->metaObject()->className();
QPoint x=temp->mapToParent(((QWidget*)Ctrl)->pos());
while(ParentName.compare("cy_main")!=0)
{
temp=temp->parentWidget();
ParentName=temp->metaObject()->className();
x=temp->mapToParent(x);
}
return x;
}
}