1

在我的应用程序中,我希望拥有本地 Windows 光标图标,而不是从 qt 资源加载/构建。

例如与标准 Windows 不同的 Qt::SplitVCursor/Qt::SplitHCursor。

Native 和 QT5 SplitHCursor

4

1 回答 1

1

查看来源qwindowscursor.cpp

switch (cursorShape) {
case Qt::SplitVCursor:
    return createPixmapCursorFromData(systemCursorSize(), standardCursorSize(), 32, vsplit_bits, vsplitm_bits);
case Qt::SplitHCursor:
    return createPixmapCursorFromData(systemCursorSize(), standardCursorSize(), 32, hsplit_bits, hsplitm_bits);
case Qt::OpenHandCursor:
    return createPixmapCursorFromData(systemCursorSize(), standardCursorSize(), 16, openhand_bits, openhandm_bits);
case Qt::ClosedHandCursor:
    return createPixmapCursorFromData(systemCursorSize(), standardCursorSize(), 16, closedhand_bits, closedhandm_bits);
case Qt::DragCopyCursor:
    return QCursor(QPixmap(copyDragCursorXpmC), 0, 0);
case Qt::DragMoveCursor:
    return QCursor(QPixmap(moveDragCursorXpmC), 0, 0);
case Qt::DragLinkCursor:
    return QCursor(QPixmap(linkDragCursorXpmC), 0, 0);
}

进而

// 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 };

看起来 Qt 使用它自己的 V/HSplit 光标位图。所以简短的回答是“不可能”。长答案是您必须修改上述行并重新编译 Qt。我怀疑您是否可以从 Windows 中获得您提到的光标,因为它看起来不标准,并且 Qt 中的位图存在是有原因的。祝你好运,如果你成功了,就提交:)

于 2015-12-26T03:00:36.710 回答