本文整理汇总了C++中QWidget::cursor方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::cursor方法的具体用法?C++ QWidget::cursor怎么用?C++ QWidget::cursor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::cursor方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: qt_symbian_set_cursor
/*
Internal function called from QWidget::setCursor()
force is true if this function is called from dispatchEnterLeave, it means that the
mouse is actually directly under this widget.
*/
void qt_symbian_set_cursor(QWidget *w, bool force)
{
static QPointer<QWidget> lastUnderMouse = 0;
if (force) {
lastUnderMouse = w;
}
else if (w->testAttribute(Qt::WA_WState_Created) && lastUnderMouse
&& lastUnderMouse->effectiveWinId() == w->effectiveWinId()) {
w = lastUnderMouse;
}
if (!S60->curWin && w && w->internalWinId())
return;
QWidget* cW = w && !w->internalWinId() ? w : QWidget::find(S60->curWin);
if (!cW || cW->window() != w->window() || !cW->isVisible() || !cW->underMouse()
|| QApplication::overrideCursor())
return;
#ifndef Q_SYMBIAN_FIXED_POINTER_CURSORS
if (S60->brokenPointerCursors)
qt_symbian_set_pointer_sprite(cW->cursor());
else
#endif
qt_symbian_setWindowCursor(cW->cursor(), w->effectiveWinId());
}
示例2: layout
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, Qt::SplashScreen) {
QWidget *main = qApp->activeWindow();
if (main != 0) {
myMainWidget = main;
myStoredCursor = main->cursor();
myMainWidget->setCursor(Qt::WaitCursor);
} else {
myMainWidget = 0;
}
setCursor(Qt::WaitCursor);
qApp->processEvents();
QBoxLayout layout(QBoxLayout::LeftToRight, this);
QLabel *label = new QLabel(::qtString(message), this);
layout.addWidget(label);
if (main == 0) {
main = QApplication::desktop();
}
move(
main->x() + main->width() / 2 - label->width() / 2 - 10,
main->y() + main->height() / 2 - label->height() / 2 - 10
);
show();
qApp->processEvents();
usleep(5000);
qApp->processEvents();
}
示例3:
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
}
}
示例4: showCursor
void QwtPanner::showCursor( bool on )
{
if ( on == d_data->hasCursor )
return;
QWidget *w = parentWidget();
if ( w == NULL || d_data->cursor == NULL )
return;
d_data->hasCursor = on;
if ( on )
{
if ( w->testAttribute( Qt::WA_SetCursor ) )
{
delete d_data->restoreCursor;
d_data->restoreCursor = new QCursor( w->cursor() );
}
w->setCursor( *d_data->cursor );
}
else
{
if ( d_data->restoreCursor )
{
w->setCursor( *d_data->restoreCursor );
delete d_data->restoreCursor;
d_data->restoreCursor = NULL;
}
else
w->unsetCursor();
}
}
示例5: showCursor
void QwtPanner::showCursor(bool on)
{
QWidget *w = parentWidget();
if ( w == NULL || d_data->cursor == NULL )
return;
if ( on )
{
#if QT_VERSION < 0x040000
if ( w->testWState(WState_OwnCursor) )
#else
if ( w->testAttribute(Qt::WA_SetCursor) )
#endif
{
delete d_data->restoreCursor;
d_data->restoreCursor = new QCursor(w->cursor());
}
w->setCursor(*d_data->cursor);
}
else
{
if ( d_data->restoreCursor )
{
w->setCursor(*d_data->restoreCursor);
delete d_data->restoreCursor;
d_data->restoreCursor = NULL;
}
else
w->unsetCursor();
}
}
示例6: QWidget
ZLQtWaitMessage::ZLQtWaitMessage(const std::string &message) : QWidget(0, 0, WStyle_Splash), myLabelText(::qtString(message)) {
QWidget *main = qApp->mainWidget();
if (main != 0) {
myCursorIsStored = true;
myStoredCursor = main->cursor();
main->setCursor(Qt::waitCursor);
} else {
myCursorIsStored = false;
}
setCursor(Qt::waitCursor);
qApp->processEvents();
if (main == 0) {
main = QApplication::desktop();
}
QPoint position = main->mapToGlobal(main->pos());
QFontMetrics metrics = fontMetrics();
const int w = metrics.width(myLabelText) + 20;
const int h = metrics.height() + 20;
resize(1, 1);
show();
setGeometry(
position.x() + (main->width() - w) / 2,
position.y() + (main->height() - h) / 2,
w, h
);
qApp->processEvents();
for (int i = 0; i < 6; ++i) {
usleep(5000);
qApp->processEvents();
}
}
示例7: viewport
bool
BioWidget::eventFilter( QObject* o, QEvent* e )
{
QWidget* w = qobject_cast<QWidget*>( o );
if ( viewport() == w )
{
if ( QEvent::MouseMove != e->type() )
return false;
QMouseEvent* event = static_cast<QMouseEvent*>(e);
//respect child widget cursor
QWidget* w = m_widgetTextObject->widgetAtPoint(event->pos() );
if ( w != m_currentHoverWidget )
{
m_currentHoverWidget = w;
if( 0 == w )
viewport()->unsetCursor();
else
{
QWidget* c = w->childAt(event->pos());
c = c ? c : w;
viewport()->setCursor( c->cursor());
}
}
return false;
}
return false;
}
示例8: hideCursor
void KoCursorPrivateAutoHideEventFilter::hideCursor()
{
m_autoHideTimer.stop();
if ( m_isCursorHidden )
return;
m_isCursorHidden = true;
QWidget* w = mouseWidget();
m_isOwnCursor = w->testAttribute(Qt::WA_SetCursor);
if ( m_isOwnCursor )
m_oldCursor = w->cursor();
w->setCursor( QCursor( Qt::BlankCursor ) );
}
示例9: hideCursor
void KCursorPrivateAutoHideEventFilter::hideCursor()
{
m_autoHideTimer.stop();
if ( m_isCursorHidden )
return;
m_isCursorHidden = true;
QWidget* w = actualWidget();
m_isOwnCursor = w->ownCursor();
if ( m_isOwnCursor )
m_oldCursor = w->cursor();
w->setCursor( KCursor::blankCursor() );
}
示例10: unhideCursor
void KoCursorPrivateAutoHideEventFilter::unhideCursor()
{
m_autoHideTimer.stop();
if ( !m_isCursorHidden )
return;
m_isCursorHidden = false;
QWidget* w = mouseWidget();
if ( w->cursor().shape() != Qt::BlankCursor ) // someone messed with the cursor already
return;
if ( m_isOwnCursor )
w->setCursor( m_oldCursor );
else
w->unsetCursor();
}
示例11: widget
void OpenGL2Common::setSpherical(bool spherical)
{
const bool isSphericalView = (spherical && hasVbo);
if (sphericalView != isSphericalView)
{
QWidget *w = widget();
const bool isBlankCursor = (w->cursor().shape() == Qt::BlankCursor);
sphericalView = isSphericalView;
if (sphericalView)
{
w->setProperty("customCursor", (int)Qt::OpenHandCursor);
if (!isBlankCursor)
w->setCursor(Qt::OpenHandCursor);
rot = QPointF(90.0, 90.0);
}
else
{
w->setProperty("customCursor", QVariant());
if (!isBlankCursor)
w->setCursor(Qt::ArrowCursor);
buttonPressed = false;
}
}
}
示例12: paint
void QTextureViewer::paint(QPainter *painter, QPaintEvent *event)
{
VOGL_NOTE_UNUSED(event);
if (m_pKtxTexture == NULL)
{
return;
}
if (!m_mipmappedTexture.is_valid() || !m_mipmappedTexture.get_num_levels())
{
return;
}
painter->save();
const uint border = 25;
const uint minDimension = 10;
uint texWidth = m_pKtxTexture->get_width();
uint texHeight = m_pKtxTexture->get_height();
uint drawWidth = vogl::math::maximum<uint>(minDimension, texWidth);
uint drawHeight = vogl::math::maximum<uint>(minDimension, texHeight);
// offset by 1 so that there is room to draw a border around the biggest mip level
painter->translate(1, 1);
// apply zoom factor using scaling
painter->scale(m_zoomFactor, m_zoomFactor);
painter->setPen(m_outlinePen);
uint numMips = m_pKtxTexture->get_num_mips();
uint maxMip = vogl::math::minimum(numMips, m_maxMipLevel);
maxMip = vogl::math::minimum(maxMip, m_mipmappedTexture.get_num_levels() - 1);
uint mipWidth = 0;
uint mipHeight = 0;
drawWidth = drawWidth >> m_baseMipLevel;
drawHeight = drawHeight >> m_baseMipLevel;
if (m_pKtxTexture->get_num_faces() == 6)
{
// adjust draw dimensions
drawWidth *= 4;
drawHeight *= 3;
}
uint minimumWidth = 0;
uint minimumHeight = drawHeight + border;
for (uint mip = m_baseMipLevel; mip <= maxMip; mip++)
{
if (m_pixmaps.contains(mip) == false && m_mipmappedTexture.is_valid())
{
QWidget* pParent = (QWidget*)this->parent();
QCursor origCursor = pParent->cursor();
pParent->setCursor(Qt::WaitCursor);
vogl::color_quad_u8* pTmpPixels = NULL;
if (m_mipmappedTexture.is_cubemap())
{
vogl::mip_level* mipLevel = m_mipmappedTexture.get_level(m_arrayIndex, 0, mip);
vogl::image_u8* image = mipLevel->get_image();
mipWidth = image->get_width();
mipHeight = image->get_height();
unsigned char tmp = 0;
unsigned int pixelsSize = image->get_total_pixels();
// store face dimensions
uint faceWidth = mipWidth;
uint faceHeight = mipHeight;
uint cubeCrossStride = faceWidth*4;
// adjust mip dimensions
mipWidth *= 4;
mipHeight *= 3;
pTmpPixels = new vogl::color_quad_u8[pixelsSize * 12];
memset(pTmpPixels, 0, pixelsSize * 12 * sizeof(vogl::color_quad_u8));
// order is +X, -X, +Y, -Y, +Z, -Z
uint faceRowOffset[6] = {faceHeight, faceHeight, 0, 2*faceHeight, faceHeight, faceHeight};
uint faceColOffset[6] = {0, 2*faceWidth, faceWidth, faceWidth, 3*faceWidth, faceWidth};
for (uint face = 0; face < m_mipmappedTexture.get_num_faces(); face++)
{
vogl::mip_level* mipLevel2 = m_mipmappedTexture.get_level(m_arrayIndex, face, mip);
vogl::image_u8* image2 = mipLevel2->get_image();
vogl::color_quad_u8* pPixels = image2->get_pixels();
// calculate write location to start of face
vogl::color_quad_u8* writeLoc = pTmpPixels + cubeCrossStride*faceRowOffset[face] + faceColOffset[face];
for (uint h = 0; h < faceHeight; h++)
{
// copy row of face into cross
//.........这里部分代码省略.........