本文整理汇总了C++中QCursor::pos方法的典型用法代码示例。如果您正苦于以下问题:C++ QCursor::pos方法的具体用法?C++ QCursor::pos怎么用?C++ QCursor::pos使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCursor
的用法示例。
在下文中一共展示了QCursor::pos方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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();
}
示例2: QMenu
void Cocos2dWidget::contextMenuEvent(QContextMenuEvent * e)
{
if (g_mainScene){
if (g_mainScene->onClickMouseKey(e->x(), e->y())){
QCursor cur = this->cursor();
QMenu *menu=new QMenu(this);
menu->addAction(m_actDelete);
int x = cur.pos().x();
int y = cur.pos().y();
menu->exec(cur.pos());
}
}
}
示例3: leaveEvent
void IconsWidget::leaveEvent(QEvent *)
{
QCursor curs;
QPoint cursPos = mapFromGlobal(curs.pos());
if (!rect().contains(cursPos))
toolTip->hide();
}
示例4: contextMenuEvent
/*
鼠标右键菜单
*/
void MainWindow::contextMenuEvent(QContextMenuEvent *event)
{
QCursor cur = this->cursor();
//创建一个属于该窗口的子菜单
QMenu *menu = new QMenu(this);
//字体设置
QFont font;
font.setFamily(QStringLiteral("SAO UI"));
font.setPointSize(12);
//用户信息
menuAction[0] = new QAction(QIcon("image/user"), tr("User"), this);
menuAction[0]->setFont(font);
connect(menuAction[0], &QAction::triggered, this, &MainWindow::UserAction);
menu->addAction(menuAction[0]);
//数据库选择Database
menuAction[1] = new QAction(QIcon("image/window"), tr("GUI"), this);
menuAction[1]->setFont(font);
connect(menuAction[1], &QAction::triggered, this, &MainWindow::DatabaseAction);
menu->addAction(menuAction[1]);
menuAction[1]->setDisabled(true);
//命令行
menuAction[2] = new QAction(QIcon("image/eye"), tr("Command"), this);
menuAction[2]->setFont(font);
connect(menuAction[2], &QAction::triggered, this, &MainWindow::CommandAction);
menu->addAction(menuAction[2]);
menuAction[2]->setDisabled(true);
//Help
menuAction[3] = new QAction(QIcon("image/help"), tr("Help"), this);
menuAction[3]->setFont(font);
connect(menuAction[3], &QAction::triggered, this, &MainWindow::HelpAction);
menu->addAction(menuAction[3]);
//退出选择键
menuAction[4] = new QAction(QIcon("image/exit"), tr("Exit"), this);
menuAction[4]->setFont(font);
connect(menuAction[4], &QAction::triggered, this, &MainWindow::ExitAction);
menu->addAction(menuAction[4]);
//判断菜单的隐藏,在没登陆之前这些菜单需要隐藏
if (userWindows.isLogin)
{
menuAction[1]->setDisabled(false);
menuAction[2]->setDisabled(false);
}
//菜单弹出位置
menu->exec(cur.pos());
}
示例5: showToolTip
void IconsWidget::showToolTip()
{
if (crashed)
return;
if (newToolTip)
makeToolTip();
QCursor curs;
QPoint cursPos = mapFromGlobal(curs.pos());
if (rect().contains(cursPos)) {
toolTip->show();
this->setFocus();
}
}
示例6: mouseMoveEvent
void IconsWidget::mouseMoveEvent(QMouseEvent *event)
{
if (crashed)
return;
QCursor cursor;
QPoint cursorPos = mapFromGlobal(cursor.pos());
if (rect().contains(cursorPos)) {
int border = 5;
QPoint point = mapToGlobal(event->pos());
QPoint point2 = mapToGlobal(QPoint(0, 0));
if (point2.y() - mainPix.height() - 6 > 0) {
toolTip->setGeometry(point.x() - mainPix.width()/2, point2.y() - mainPix.height()-6,
mainPix.width(), mainPix.height());
} else {
toolTip->setGeometry(point.x() - mainPix.width()/2, point2.y() + height() + border,
mainPix.width(), mainPix.height());
}
}
}
示例7: contextMenuEvent
void ComparisonLineChart::contextMenuEvent(QContextMenuEvent *event){
QCursor cur = this->cursor();
context_menu_->exec(cur.pos());
}
示例8: myUpdate
//std::string readShaderCode(const char *fileName)
//{
// std::ifstream input(fileName);
//
// if(!input.good())
// {
// qDebug() << "File not found" << fileName;
// exit(1);
// }
// return std::string(std::istreambuf_iterator<char>(input),
// std::istreambuf_iterator<char>());
//}
//void MyGLWindow::CompileShaders()
//{
// GLuint vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
// GLuint fragShaderID=glCreateShader(GL_FRAGMENT_SHADER);
// const char* adapter[1];
//
// std::string shaderCode= readShaderCode("../shaders/LightingVertexShaderCode.glsl");
// adapter[0] = shaderCode.c_str();
// glShaderSource(vertexShaderID,1,adapter,0);
//
// shaderCode= readShaderCode("../shaders/LightingFragmentShaderCode.glsl");
// adapter[0] = shaderCode.c_str();
// glShaderSource(fragShaderID,1,adapter,0);
//
// glCompileShader(vertexShaderID);
// glCompileShader(fragShaderID);
//
// GLint compileStatus;
// glGetShaderiv(vertexShaderID,GL_COMPILE_STATUS,&compileStatus);
// if(compileStatus != GL_TRUE)
// {
// GLint logLength;
// glGetShaderiv(vertexShaderID,GL_INFO_LOG_LENGTH, &logLength);
// char* buffer = new char [logLength];
// GLsizei bitBucket;
// glGetShaderInfoLog(vertexShaderID,logLength,&bitBucket,buffer);
// qDebug() <<buffer;
// delete [] buffer;
// }
// glGetShaderiv(fragShaderID,GL_COMPILE_STATUS,&compileStatus);
// if(compileStatus != GL_TRUE)
// {
// GLint logLength;
// glGetShaderiv(fragShaderID,GL_INFO_LOG_LENGTH, &logLength);
// char* buffer = new char [logLength];
// GLsizei bitBucket;
// glGetShaderInfoLog(fragShaderID,logLength,&bitBucket,buffer);
// qDebug() <<buffer;
// delete [] buffer;
// }
//
// programID = glCreateProgram();
// glAttachShader(programID,vertexShaderID);
// glAttachShader(programID,fragShaderID);
//
// glLinkProgram(programID);
//
// glUseProgram(programID);
//
// glDeleteShader(vertexShaderID);
// glDeleteShader(fragShaderID);
//}
void MyGLWindow::myUpdate()
{
if(GetAsyncKeyState('E'))
{
QCursor mouse = cursor();
QPoint mousePosition = mouse.pos();
cam.mouseUpdate(glm::vec2(mousePosition.x(),mousePosition.y()));
}
if(GetAsyncKeyState('W'))
{
cam.moveForward();
}
if(GetAsyncKeyState('S'))
{
cam.moveBackward();
}
if(GetAsyncKeyState('A'))
{
cam.strafeLeft();
}
if(GetAsyncKeyState('D'))
{
cam.strafeRight();
}
if(GetAsyncKeyState('R'))
{
cam.moveUp();
}
if(GetAsyncKeyState('F'))
{
cam.moveDown();
}
if(GetAsyncKeyState('Y'))
{
lightPosition[1]+=0.1f;
//.........这里部分代码省略.........