本文整理汇总了C++中QCursor::setPos方法的典型用法代码示例。如果您正苦于以下问题:C++ QCursor::setPos方法的具体用法?C++ QCursor::setPos怎么用?C++ QCursor::setPos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCursor
的用法示例。
在下文中一共展示了QCursor::setPos方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mouseMoveEvent
void OpenGLWidget::mouseMoveEvent(QMouseEvent * mouseEvent)
{
// Ignore events that return mouse to center.
if(mouseEvent->pos() == QPoint(this->width() / 2, this->height() / 2))
{
return;
}
const int xDelta = mouseEvent->x() - (this->width() / 2);
const int yDelta = mouseEvent->y() - (this->height() / 2);
static const float sensitivity = 0.25f;
m_yawRotation += xDelta * sensitivity;
m_pitchRotation -= yDelta * sensitivity;
if(m_pitchRotation < -89.0f)
{
m_pitchRotation = -89.0f;
}
if(m_pitchRotation > 89.0f)
{
m_pitchRotation = 89.0f;
}
const float yawRad = m_yawRotation * 3.14 / 180;
const float pitchRad = m_pitchRotation * 3.14 / 180;
m_cameraFront.setX(std::cos(pitchRad) * std::cos(yawRad));
m_cameraFront.setY(std::sin(pitchRad));
m_cameraFront.setZ(std::cos(pitchRad) * std::sin(yawRad));
QCursor cursor = this->cursor();
cursor.setPos(mapToGlobal(QPoint(this->width() / 2, this->height() / 2)));
setCursor(cursor);
}
示例2: mouseMoveEvent
void Preview::mouseMoveEvent( QMouseEvent* e )
{
e;
QCursor c = cursor();
QPoint mapFromGlobal = this->mapFromGlobal( c.pos() );
if ( GetAsyncKeyState( VK_LBUTTON ) < 0 && mapFromGlobal.x() >= 0 && mapFromGlobal.x() <= width() &&
mapFromGlobal.y() >= 0 && mapFromGlobal.y() <= height() && MouseInput::globalMouseInput.oldMousePosition != glm::vec2( c.pos().x() , c.pos().y() ) )
{
if ( !MouseInput::globalMouseInput.getDeltaTracking() )MouseInput::globalMouseInput.setDeltaTracking( true );
glm::vec2 oldPos = MouseInput::globalMouseInput.oldMousePosition;
MouseInput::globalMouseInput.updateMousePosition( glm::vec2( c.pos().x() , c.pos().y() ) );
c.setPos( QPoint( oldPos.x , oldPos.y ) );
c.setShape( Qt::BlankCursor );
}
else if ( MouseInput::globalMouseInput.oldMousePosition != glm::vec2( c.pos().x() , c.pos().y() ) )
{
c.setShape( Qt::ArrowCursor );
if ( MouseInput::globalMouseInput.getDeltaTracking() )MouseInput::globalMouseInput.setDeltaTracking( false );
MouseInput::globalMouseInput.oldMousePosition = glm::vec2( c.pos().x() , c.pos().y() );
MouseInput::globalMouseInput.updateMousePosition( glm::vec2( c.pos().x() , c.pos().y() ) );
}
clearFocus();
setCursor( c );
setFocus();
}
示例3: keyPressEvent
//Tekla bat sakatzean sortzen den ekintza
void Mandomugitu::keyPressEvent( QKeyEvent * event )
{
// X eta Y ardatzetako posizioa bertan gordeko dira
int posx,posy;
QCursor pos;
//X eta Y ardatzeko posizioa lortzeko x() eta y() funtzioak erabiltzeko objektuaren erazagupena
QPoint posiz;
//rfcomm0 portua ireki
FILE * portua = fopen ("/dev/rfcomm0", "w");
//fputc funtzioan char motakoak bidali behar direnez posx eta posy aldagaien 'karaktere' motako aldagaiak
char cposx,cposy;
//idatzitako teklaren kodea jasotzen da
const int botoi = event->key();
//Tekla bakoitzaren kodearekin konparatzen da, eta koinziditzen badute, letra hori bidaltzen zaio pololuri
switch (botoi)
{
//A letraren kodea,Wiimote-ko A botoia sakatzen dagoen bitartean kurtsorearen posizioak bidaliko zaizkio robotaren programari
case Qt::Key_A :
//posiz objektuan pos() funtzioak itzultzen dituen pantailako uneko x eta y balioak gordeko dira
posiz = QCursor::pos();
//Pantailak har dezakeen X eta Y posiziorik altuena 1365 eta 767 direnez da,eta balio hauek handiegiak direnez 13,65 eta 7,67 balioarengatik zatituko da
//Horrela posx eta posy-k izango duten baliorik handiena 100 izango da
//posx aldagaiean posiz objektuko x posizioa esleituko da
posx = posiz.x()/13.65;
//posy aldagaiean posiz objektuko y posizioa esleituko da
posy = posiz.y()/7.67;
//Robotaren programari bidaliko zaion 'a' tekla esleitzen da
tekla = 'a';
//fputc erabili ahal izateko egiten den (char) castinga cposx eta cposy-en esleituz
cposx =(char)posx;
cposy =(char)posy;
//'a' tekla bidaliko zaio robotaren programari Wiimote-ko 'A' botoia sakatu dela jakinarazteko
fputc(tekla, portua);
//Kurtsorearen uneko x eta y posizioak bidaliko zaizkio robotaren programari RFCOMM0 portutik
fputc(cposy, portua);
fputc(cposx, portua);
break;
//B tekla bidaliko zaio robotak frenatzea nahi dugunean
case Qt::Key_B :
tekla = 'b';
fputc(tekla, portua);
break;
//Pantailaren posizioa kalibratzen da
case Qt::Key_1:
pos.setPos(683,384);
break;
}
fclose(portua);
}
示例4: initializeGL
void Preview::initializeGL()
{
CommonGraphicsCommands::initializeGlobalGraphics();
GameObjectManager::globalGameObjectManager.initialize();
std::string err;
ShaderInfo* shader = GraphicsShaderManager::globalShaderManager.createShaderInfo( FileReader( "assets/shaders/VertexShader.glsl" ).c_str() , FileReader( "assets/shaders/FragmentShader.glsl" ).c_str() , &err );
std::cout << err.c_str() << std::endl;
renderable = GraphicsRenderingManager::globalRenderingManager.addRenderable();
renderable->geometryInfo = 0;
renderable->shaderInfo = shader;
renderable->culling = CT_BACK;
renderable->depthTestEnabled = true;
renderable->sharedUniforms = &GraphicsSharedUniformManager::globalSharedUniformManager;
renderable->initialize( 10 , 1 );
colorTexture = GraphicsTextureManager::globalTextureManager.addTexture( 0 , 0 , 0 , 0 );
renderable->addTexture( colorTexture );
GameObject* previewModel = GameObjectManager::globalGameObjectManager.addGameObject();
previewModel->addComponent( renderable );
animation = new AnimationRenderingInfo;
previewModel->addComponent( animation );
Camera* camera = GraphicsCameraManager::globalCameraManager.addCamera();
camera->direction = glm::normalize( glm::vec3( -1 , 0 , -1 ) );
camera->initializeRenderManagers();
camera->nearestObject = 0.01f;
camera->addRenderList( &GraphicsRenderingManager::globalRenderingManager );
fpsInput = new FirstPersonCameraInput;
fpsInput->moveSensitivity = 1;
fpsInput->rotationSensitivity = 0.1f;
GameObject* cameraMan = GameObjectManager::globalGameObjectManager.addGameObject();
cameraMan->translate = glm::vec3( 6 , 5 , 15 );
cameraMan->addComponent( camera );
cameraMan->addComponent( fpsInput );
MouseInput::globalMouseInput.updateOldMousePosition = false;
setMouseTracking( true );
QCursor c = cursor();
c.setPos( mapToGlobal( QPoint( width() / 2 , height() / 2 ) ) );
c.setShape( Qt::BlankCursor );
setCursor( c );
MouseInput::globalMouseInput.updateMousePosition( glm::vec2( width() / 2 , height() / 2 ) );
timer = new QTimer();
connect( timer , SIGNAL( timeout() ) , this , SLOT( update() ) );
timer->start( 0 );
}
示例5: mousePressEvent
void GameView::mousePressEvent(QMouseEvent*)
{
if (m_editor->isGameMode())
{
setFocus();
setMouseTracking(true);
grabMouse();
grabKeyboard();
QCursor c = cursor();
c.setPos(mapToGlobal(QPoint(width() / 2, height() / 2)));
c.setShape(Qt::BlankCursor);
setCursor(c);
m_editor->getEngine().getInputSystem().enable(true);
m_isInputHandling = true;
}
}
示例6: on_hasiButton_clicked
//Play botoia sakatzen bada sortzen den ekintza
void Mandomugitu::on_hasiButton_clicked()
{
//RFCOMM0 portua ireki
FILE * portua = fopen ("/dev/rfcomm0", "w");
QMessageBox infoBox;
//Kurtsorearen posizioa aldatzeko erabiliko den objektua
QCursor pos;
infoBox.information(this,"Kalibratua","Wii-ko mandoa ondo kalibratua dago, aurrera!");
tekla='h';
hasiBai = true;
stopBai = false;
//Kurtsorea pantailaren erdian kokatuko da
pos.setPos(683,384);
//Robotaren programari bidaltzeko zaio h tekla adierazteko robotaren mugimendu funtzionamentua prest dagoela
fputc(tekla,portua);
fclose(portua);
}
示例7: mouseMoveEvent
void GameView::mouseMoveEvent(QMouseEvent* event)
{
if (!m_isInputHandling)
{
return;
}
int half_width = width() / 2;
int half_height = height() / 2;
if (event->x() != half_width || event->y() != half_height)
{
auto& input_system = m_editor->getEngine().getInputSystem();
input_system.injectMouseXMove(event->x() - half_width);
input_system.injectMouseYMove(event->y() - half_height);
QCursor c = cursor();
c.setPos(mapToGlobal(QPoint(half_width, half_height)));
c.setShape(Qt::BlankCursor);
setCursor(c);
}
}
示例8: moveCursor
void MouseGotoPixelEditor::moveCursor(int column, int row) {
QCursor cursor;
cursor.setPos(column, row);
}