本文整理汇总了C++中QCursor类的典型用法代码示例。如果您正苦于以下问题:C++ QCursor类的具体用法?C++ QCursor怎么用?C++ QCursor使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QCursor类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: leaveEvent
void IconsWidget::leaveEvent(QEvent *)
{
QCursor curs;
QPoint cursPos = mapFromGlobal(curs.pos());
if (!rect().contains(cursPos))
toolTip->hide();
}
示例2: wireSlot
void CircuitsWidget::wireSlot(int, Component *c) {
QCursor cr;
cr.setShape(Qt::CrossCursor);
setCursor(cr);
connectingComponent = true;
componentOnConnection = c;
}
示例3: updateCursor
void QDragManager::updateCursor()
{
#ifndef QT_NO_CURSOR
if (willDrop) {
if (qt_qws_dnd_deco)
qt_qws_dnd_deco->show();
if (currentActionForOverrideCursor != global_accepted_action) {
QApplication::changeOverrideCursor(QCursor(dragCursor(global_accepted_action), 0, 0));
currentActionForOverrideCursor = global_accepted_action;
}
} else {
QCursor *overrideCursor = QApplication::overrideCursor();
if (!overrideCursor || overrideCursor->shape() != Qt::ForbiddenCursor) {
QApplication::changeOverrideCursor(QCursor(Qt::ForbiddenCursor));
currentActionForOverrideCursor = Qt::IgnoreAction;
}
#ifndef EMSCRIPTEN
// Hiding the pixmap feels weird, and doesn't match the desktop behaving;
// so I've disabled it for Emscripten.
if (qt_qws_dnd_deco)
qt_qws_dnd_deco->hide();
#endif
}
#endif
}
示例4: switch
QVariant Util::decorationForVariant(const QVariant &value)
{
switch (value.type()) {
case QVariant::Brush:
{
const QBrush b = value.value<QBrush>();
if (b.style() != Qt::NoBrush) {
QPixmap p(16, 16);
p.fill(QColor(0, 0, 0, 0));
QPainter painter(&p);
painter.setBrush(b);
painter.drawRect(0, 0, p.width() - 1, p.height() - 1);
return p;
}
}
case QVariant::Color:
{
const QColor c = value.value<QColor>();
if (c.isValid()) {
QPixmap p(16, 16);
QPainter painter(&p);
painter.setBrush(QBrush(c));
painter.drawRect(0, 0, p.width() - 1, p.height() - 1);
return p;
}
}
case QVariant::Cursor:
{
const QCursor c = value.value<QCursor>();
if (!c.pixmap().isNull()) {
return c.pixmap().scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation);
}
}
case QVariant::Icon:
{
return value;
}
case QVariant::Pen:
{
const QPen pen = value.value<QPen>();
if (pen.style() != Qt::NoPen) {
QPixmap p(16, 16);
p.fill(QColor(0, 0, 0, 0));
QPainter painter(&p);
painter.setPen(pen);
painter.translate(0, 8 - pen.width() / 2);
painter.drawLine(0, 0, p.width(), 0);
return p;
}
}
case QVariant::Pixmap:
{
const QPixmap p = value.value<QPixmap>();
return QVariant::fromValue(p.scaled(16, 16, Qt::KeepAspectRatio, Qt::FastTransformation));
}
default: break;
}
return QVariant();
}
示例5: 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);
}
示例6:
SetWaitCursor::~SetWaitCursor()
{
if (m_guiApp) {
RG_DEBUG << "SetWaitCursor::SetWaitCursor() : restoring normal cursor\n";
QWidget* viewport = 0;
QCursor currentCompositionViewCursor;
if ((m_guiApp->getView() &&
m_guiApp->getView()->getTrackEditor() &&
m_guiApp->getView()->getTrackEditor()->getCompositionView() &&
m_guiApp->getView()->getTrackEditor()->getCompositionView()->viewport())) {
viewport = m_guiApp->getView()->getTrackEditor()->getCompositionView()->viewport();
currentCompositionViewCursor = viewport->cursor();
}
m_guiApp->setCursor(m_saveCursor);
if (viewport) {
if (currentCompositionViewCursor.shape() == Qt::WaitCursor) {
viewport->setCursor(m_saveCompositionViewCursor);
} else {
viewport->setCursor(currentCompositionViewCursor); // because m_guiApp->setCursor() has replaced it
}
}
// otherwise, it's been modified elsewhere, so leave it as is
}
}
示例7: cursor
void OpenGLWindow::ShowCursor()
{
cursorClip = false;
QCursor c = cursor();
c.setShape(Qt::ArrowCursor);
setCursor(c);
}
示例8: onStateChanged
void MainDialog::onStateChanged(int state, short disconnectStatus)
{
QColor clr = BTN_RED;
if( state == CloseWaitState || state == ProgressState ) {
QCursor* ovrCur = QApplication::overrideCursor();
if( ovrCur == NULL || ovrCur->shape() != Qt::WaitCursor )
QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
clr = BTN_YELLOW;
}
if( state == EstablishState ) {
QApplication::restoreOverrideCursor();
startButton_->setEnabled( false );
stopButton_->setEnabled( true );
clr = BTN_GREEN;
}
else {
QApplication::restoreOverrideCursor();
startButton_->setEnabled(true);
stopButton_->setEnabled(false);
}
QPalette pal;
pal.setColor(QPalette::Button, clr);
colorButton_->setPalette(pal);
}
示例9: hideMouseCursor
void GenericCodeEditor::hideMouseCursor()
{
#ifdef Q_OS_MAC
return; // LATER: for some reason this crashes on osx. we should try to figure out why
#endif
QCursor * overrideCursor = QApplication::overrideCursor();
if (!overrideCursor || overrideCursor->shape() != Qt::BlankCursor)
QApplication::setOverrideCursor( Qt::BlankCursor );
}
示例10: switch
void GL_insert_ball_layer_2::keyPressEvent(QKeyEvent *e) {
switch (e->key()) {
case Qt::Key_Control:
// widget->cursor()->setShape(Qt::CrossCursor);
QCursor c = widget->get_default_cursor();
c.setShape(Qt::CrossCursor);
widget->setCursor(c);
break;
}
}
示例11: switch
void GL_navigate_layer_2::mouseReleaseEvent(QMouseEvent *e) {
switch (s) {
case PAN:
s = NONE;
break;
case ZOOM:
s = NONE;
break;
case ZOOM_RECT:
rubber_band->hide();
delete rubber_band;
rubber_band = 0;
widget->repaintGL();
if((e->x() != first_x) && (e->y() != first_y)) {
double x, y, xfirst2, yfirst2;
x = widget->x_real(e->x());
y = widget->y_real(e->y());
xfirst2 = widget->x_real(first_x);
yfirst2 = widget->y_real(first_y);
double xmin, xmax, ymin, ymax;
if(x < xfirst2) {xmin = x; xmax = xfirst2;}
else {xmin = xfirst2; xmax = x;};
if(y < yfirst2) {ymin = y; ymax = yfirst2;}
else {ymin = yfirst2; ymax = y;};
if (is_alt(e)) widget->set_window(xmin, xmax, ymin, ymax);
else smooth_zoom(xmin, xmax, ymin, ymax);
} else if (widget->has_boundingbox()) {
// jump to bounding box
double x_min = widget->get_bounding_xmin();
double x_max = widget->get_bounding_xmax();
double y_min = widget->get_bounding_ymin();
double y_max = widget->get_bounding_ymax();
if (x_min != x_max && y_min != y_max) {
double margin_percent= BOUNDING_BOX_MARGIN_PERCENT;
double x_margin = (x_max - x_min) * margin_percent;
double y_margin = (y_max - y_min) * margin_percent;
x_min -= x_margin; x_max += x_margin;
y_min -= y_margin; y_max += y_margin;
if (is_alt(e)) widget->set_window(x_min, x_max, y_min, y_max);
else smooth_zoom(x_min, x_max, y_min, y_max);
}
}
s = NONE;
break;
}
if (is_pure(e) || is_alt(e) || is_shift(e)) widget->setCursor(QCursor( QPixmap( (const char**)hand_xpm)));
else {
QCursor c = widget->get_default_cursor();
c.setShape(Qt::CrossCursor);
widget->setCursor(c);
}
}
示例12: 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());
}
示例13: fopen
//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);
}
示例14: 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());
}
}
}
示例15: makeToolTip
void IconsWidget::showToolTip()
{
if (crashed)
return;
if (newToolTip)
makeToolTip();
QCursor curs;
QPoint cursPos = mapFromGlobal(curs.pos());
if (rect().contains(cursPos)) {
toolTip->show();
this->setFocus();
}
}