本文整理汇总了C++中QCursor::hotSpot方法的典型用法代码示例。如果您正苦于以下问题:C++ QCursor::hotSpot方法的具体用法?C++ QCursor::hotSpot怎么用?C++ QCursor::hotSpot使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QCursor
的用法示例。
在下文中一共展示了QCursor::hotSpot方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: scaledToScreen
// static
QCursor MapEditorTool::scaledToScreen(const QCursor& unscaled_cursor)
{
auto scale = Settings::getInstance().getSetting(Settings::General_PixelsPerInch).toReal() / 96.0;
if (unscaled_cursor.shape() == Qt::BitmapCursor
&& scale > 1.5)
{
// Need to scale our low res image for high DPI screen
const auto unscaled_pixmap = unscaled_cursor.pixmap();
const auto scaled_hotspot = QPointF{ unscaled_cursor.hotSpot() } * scale;
return QCursor{ unscaled_pixmap.scaledToWidth(unscaled_pixmap.width() * scale, Qt::SmoothTransformation),
qRound(scaled_hotspot.x()), qRound(scaled_hotspot.y()) };
}
else
{
return unscaled_cursor;
}
}
示例2: qt_createPixmapCursor
static HCURSOR qt_createPixmapCursor( const QCursor &cursor, const QPixmap &pixmap, const QPoint &hotspot )
{
QSize size;
/* calculate size of cursor */
QPoint pt = hotspot - cursor.hotSpot();
QPoint pixmap_point( 0, 0 );
QPoint cursor_point( 0, 0 );
if ( qWinVersion() <= Qt::WV_95 ) {
/* Win95 can only fixed size */
size.setWidth( GetSystemMetrics ( SM_CXCURSOR ) );
size.setHeight ( GetSystemMetrics ( SM_CYCURSOR ) );
} else {
/* calculate size (enlarge if needed) */
const QBitmap *tmp = cursor.bitmap();
/* Only bitmap cursors allowed... */
if ( tmp ) {
QPoint point;
// curent size
size = pixmap.size();
// calc position of lower right cursor pos
point.setX( pt.x() + tmp->size().width() );
point.setY( pt.y() + tmp->size().height() );
// resize when cursor to large
if ( point.x() > pixmap.width() )
size.setWidth( point.x() );
if ( point.y() > pixmap.height() )
size.setHeight( point.y() );
// calc upper left corner where both pixmaps have to be drawn
if ( pt.x() >= 0 ) {
cursor_point.setX( pt.x() );
} else {
pixmap_point.setX( -pt.x() );
// negative position -> resize
size.setWidth( size.width() - pt.x() );
}
if ( pt.y() >= 0 ) {
cursor_point.setX( pt.x() );
} else {
pixmap_point.setY( -pt.y() );
// negative position -> resize
size.setHeight( size.height() - pt.y() );
}
}
}
/* Mask */
QBitmap andMask( size );
BitBlt( andMask.handle(), 0, 0, size.width(), size.height(), NULL, 0, 0, WHITENESS );
if ( pixmap.mask() )
BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), pixmap.mask() ->handle(), 0, 0, SRCAND );
else
BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), NULL, 0, 0, BLACKNESS );
const QBitmap *curMsk = cursor.mask();
if ( curMsk )
BitBlt( andMask.handle(), cursor_point.x(), cursor_point.y(), curMsk->width(), curMsk->height(), curMsk->handle(), 0, 0, SRCAND );
/* create Pixmap */
QPixmap xorMask( size );
xorMask.fill ( Qt::color1 );
QPainter paint2( &xorMask );
paint2.drawPixmap( pixmap_point, pixmap );
QPixmap pm;
pm.convertFromImage( cursor.bitmap() ->convertToImage().convertDepth( 8 ) );
pm.setMask( *cursor.mask() );
paint2.drawPixmap ( cursor_point, pm );
paint2.end();
#ifdef DEBUG_QDND_SRC
andMask.save ( "pand.png", "PNG" );
xorMask.save ( "pxor.png", "PNG" );
#endif
HCURSOR cur = qt_createPixmapCursor ( qt_display_dc(), xorMask, andMask, hotspot, size );
if ( !cur ) {
qWarning( "Error creating cursor: %d", GetLastError() );
}
return cur;
}
示例3: createSystemCursor
HCURSOR QWindowsCursor::createSystemCursor(const QCursor &c)
{
int hx = c.hotSpot().x();
int hy = c.hotSpot().y();
const Qt::CursorShape cshape = c.shape();
if (cshape == Qt::BitmapCursor) {
const QPixmap pixmap = c.pixmap();
if (!pixmap.isNull())
if (const HCURSOR hc = createPixmapCursor(pixmap, hx, hy))
return hc;
}
// Non-standard Windows cursors are created from bitmaps
static const uchar vsplit_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0x7f, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0x80, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0xe0, 0x03, 0x00,
0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uchar vsplitm_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0xc0, 0x01, 0x00, 0x00, 0xe0, 0x03, 0x00, 0x00, 0xf0, 0x07, 0x00,
0x00, 0xf8, 0x0f, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
0x00, 0xc0, 0x01, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00, 0x80, 0xff, 0xff, 0x00,
0x80, 0xff, 0xff, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0xc0, 0x01, 0x00,
0x00, 0xc0, 0x01, 0x00, 0x00, 0xf8, 0x0f, 0x00, 0x00, 0xf0, 0x07, 0x00,
0x00, 0xe0, 0x03, 0x00, 0x00, 0xc0, 0x01, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uchar hsplit_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
0x00, 0x41, 0x82, 0x00, 0x80, 0x41, 0x82, 0x01, 0xc0, 0x7f, 0xfe, 0x03,
0x80, 0x41, 0x82, 0x01, 0x00, 0x41, 0x82, 0x00, 0x00, 0x40, 0x02, 0x00,
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00,
0x00, 0x40, 0x02, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uchar hsplitm_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe2, 0x47, 0x00, 0x00, 0xe3, 0xc7, 0x00,
0x80, 0xe3, 0xc7, 0x01, 0xc0, 0xff, 0xff, 0x03, 0xe0, 0xff, 0xff, 0x07,
0xc0, 0xff, 0xff, 0x03, 0x80, 0xe3, 0xc7, 0x01, 0x00, 0xe3, 0xc7, 0x00,
0x00, 0xe2, 0x47, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00,
0x00, 0xe0, 0x07, 0x00, 0x00, 0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
static const uchar openhand_bits[] = {
0x80,0x01,0x58,0x0e,0x64,0x12,0x64,0x52,0x48,0xb2,0x48,0x92,
0x16,0x90,0x19,0x80,0x11,0x40,0x02,0x40,0x04,0x40,0x04,0x20,
0x08,0x20,0x10,0x10,0x20,0x10,0x00,0x00};
static const uchar openhandm_bits[] = {
0x80,0x01,0xd8,0x0f,0xfc,0x1f,0xfc,0x5f,0xf8,0xff,0xf8,0xff,
0xf6,0xff,0xff,0xff,0xff,0x7f,0xfe,0x7f,0xfc,0x7f,0xfc,0x3f,
0xf8,0x3f,0xf0,0x1f,0xe0,0x1f,0x00,0x00};
static const uchar closedhand_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0x48,0x32,0x08,0x50,
0x10,0x40,0x18,0x40,0x04,0x40,0x04,0x20,0x08,0x20,0x10,0x10,
0x20,0x10,0x20,0x10,0x00,0x00,0x00,0x00};
static const uchar closedhandm_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0xb0,0x0d,0xf8,0x3f,0xf8,0x7f,
0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
wchar_t *sh = 0;
switch (c.shape()) { // map to windows cursor
case Qt::ArrowCursor:
sh = IDC_ARROW;
break;
case Qt::UpArrowCursor:
sh = IDC_UPARROW;
break;
case Qt::CrossCursor:
sh = IDC_CROSS;
break;
case Qt::WaitCursor:
sh = IDC_WAIT;
break;
case Qt::IBeamCursor:
sh = IDC_IBEAM;
break;
case Qt::SizeVerCursor:
sh = IDC_SIZENS;
break;
case Qt::SizeHorCursor:
//.........这里部分代码省略.........