本文整理汇总了C++中QWindow::height方法的典型用法代码示例。如果您正苦于以下问题:C++ QWindow::height方法的具体用法?C++ QWindow::height怎么用?C++ QWindow::height使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWindow
的用法示例。
在下文中一共展示了QWindow::height方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: __adjustResizeWindow
void Wpp::__adjustResizeWindow()
{
int kbHeight = 280*wpp::qt::Wpp::getInstance().dp2px();
QWindow *window = QGuiApplication::focusWindow();
window->setHeight( window->height() - kbHeight );
qDebug() << __FUNCTION__ << ":resize-ok-to:" << window->size();
}
示例2: eventFilter
bool MouseEventFilter::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::MouseMove)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if(mouseEvent)
{
ApplicationManager::singleton()->setMouseX(mouseEvent->pos().x());
ApplicationManager::singleton()->setMouseY(mouseEvent->pos().y());
if(mouseEvent->buttons() && Qt::LeftButton && ApplicationManager::singleton()->grabbingWindowMoveHandle() &&
ApplicationManager::singleton()->windowControlButtonsEnabled())
{
QPoint diffPosition = mouseEvent->pos() - mousePos.toPoint();
QPoint newPosition = ApplicationManager::singleton()->window()->position() + diffPosition;
int oldWindowWidth = ApplicationManager::singleton()->window()->width();
if(ApplicationManager::singleton()->showNormal())
{
int windowWidth = ApplicationManager::singleton()->window()->width();
ApplicationManager::singleton()->window()->setPosition(newPosition.x() + (oldWindowWidth - windowWidth) * (mousePos.x() / oldWindowWidth), newPosition.y());
mousePos.setX(mousePos.x() - (oldWindowWidth - windowWidth) * (mousePos.x() / oldWindowWidth));
}
else
{
ApplicationManager::singleton()->window()->setPosition(newPosition);
}
}
else if(mouseEvent->buttons() && Qt::LeftButton && ApplicationManager::singleton()->grabbingWindowResizeHandle() &&
ApplicationManager::singleton()->windowControlButtonsEnabled())
{
QPoint diffPosition = mouseEvent->pos() - mousePos.toPoint();
mousePos = mouseEvent->pos();
QWindow *window = ApplicationManager::singleton()->window();
int newWidth = window->width() + diffPosition.x();
int newHeight = window->height() + diffPosition.y();
if(newWidth < 1024) newWidth = 1024;
if(newHeight < 600) newHeight = 600;
window->setGeometry(window->position().x(), window->position().y(), newWidth, newHeight);
}
}
}
else if(event->type() == QEvent::MouseButtonPress)
{
QMouseEvent *mouseEvent = static_cast<QMouseEvent*>(event);
if(mouseEvent)
{
mousePos = mouseEvent->pos();
}
}
return QObject::eventFilter(obj, event);
}
示例3: testPositionAndSize
void tst_QWindowContainer::testPositionAndSize()
{
QWindow *window = new QWindow();
window->setGeometry(300, 400, 500, 600);
QWidget *container = QWidget::createWindowContainer(window);
container->setGeometry(50, 50, 200, 200);
container->show();
QVERIFY(QTest::qWaitForWindowExposed(container));
QCOMPARE(window->x(), 0);
QCOMPARE(window->y(), 0);
QCOMPARE(window->width(), container->width());
QCOMPARE(window->height(), container->height());
}
示例4: cursorMoved
void QHimePlatformInputContext::cursorMoved()
{
dbg(" QHimePlatformInputContext::cursorMoved()\n");
QWindow *inputWindow = qApp->focusWindow();
if (!inputWindow)
return;
QRect r = qApp->inputMethod()->cursorRectangle().toRect();
if(!r.isValid())
return;
// hime server will clear the string if the cursor is moved, make sure the x,y is valid
int x = r.left(), y = r.bottom();
if (x > inputWindow->width() || y > inputWindow->height() || x < 0 || y < 0)
return;
if (hime_ch && (x != last_x || y != last_y)) {
last_x = x; last_y = y;
dbg("move cursor %d, %d\n", x, y);
hime_im_client_set_cursor_location(hime_ch, x, y);
}
}
示例5: realOnKeyboardVisibleChanged
void Wpp::realOnKeyboardVisibleChanged()
{
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
qDebug() << __FUNCTION__;
//#ifdef Q_OS_IOS
QScreen *screen = QGuiApplication::primaryScreen();
QWindow *window = QGuiApplication::focusWindow();
QInputMethod *inputMethod = QGuiApplication::inputMethod();
if ( inputMethod->isVisible() )
{
if ( m_softInputMode == ADJUST_RESIZE && window != 0 && screen != 0 )
{
#ifdef Q_OS_IOS
QRectF kbRect = inputMethod->keyboardRectangle();
#endif
#ifdef Q_OS_ANDROID
/*
Rect r = new Rect();
View rootview = this.getWindow().getDecorView(); // this = activity
rootview.getWindowVisibleDisplayFrame(r);
*/
QAndroidJniObject visibleFrameRect("android/graphics/Rect","()V");
qDebug() << __FUNCTION__ << "visibleFrameRect.isValid()=" << visibleFrameRect.isValid();
QAndroidJniObject activity = QtAndroid::androidActivity();
qDebug() << __FUNCTION__ << "activity.isValid()=" << activity.isValid();
QAndroidJniObject androidWindow = activity.callObjectMethod(
"getWindow","()Landroid/view/Window;");
qDebug() << __FUNCTION__ << "androidWindow.isValid()=" << androidWindow.isValid();
QAndroidJniObject rootview = androidWindow.callObjectMethod(
"getDecorView","()Landroid/view/View;");
qDebug() << __FUNCTION__ << "rootview.isValid()=" << rootview.isValid();
//rootview.callMethod<void>("getWindowVisibleDisplayFrame","(Landroid/graphics/Rect;)V",visibleFrameRect.object<jobject>());
rootview.callMethod<jboolean>("getLocalVisibleRect","(Landroid/graphics/Rect;)Z",visibleFrameRect.object<jobject>());
qDebug() << __FUNCTION__ << "rootview.isValid()=" << rootview.isValid();
qDebug() << __FUNCTION__ << "visibleFrameRect.isValid()=" << visibleFrameRect.isValid();
jint visibleFrameTop = visibleFrameRect.getField<jint>("top");
qDebug() << __FUNCTION__ << "visibleFrameRect.visibleFrameTop=" << visibleFrameTop;
jint visibleFrameLeft = visibleFrameRect.getField<jint>("left");
qDebug() << __FUNCTION__ << "visibleFrameRect.visibleFrameLeft=" << visibleFrameLeft;
jint visibleFrameWidth = visibleFrameRect.callMethod<jint>("width","()I");
qDebug() << __FUNCTION__ << "visibleFrameRect.width()=" << visibleFrameWidth;
jint visibleFrameHeight = visibleFrameRect.callMethod<jint>("height","()I");
qDebug() << __FUNCTION__ << "visibleFrameRect.height()=" << visibleFrameHeight;
int keyboardHeight = 0;
if ( screen != 0 )
{
qDebug() << __FUNCTION__ << "screen.height()=" << screen->size().height();
keyboardHeight = screen->size().height() - visibleFrameHeight;
qDebug() << __FUNCTION__ << "keyboardHeight=" << keyboardHeight;
}
QRectF kbRect(0, visibleFrameHeight, visibleFrameWidth, keyboardHeight);//assume keyboard from bottom side
#endif
qDebug() << __FUNCTION__ << "kbRect=" << kbRect;
window->showNormal();
if ( window->height() == screen->size().height() )
{
qDebug() << __FUNCTION__ << ":origSize=" << window->size();
Q_ASSERT( kbRect.width() == (qreal)window->width() );//assume keyboard appears from bottom side of app window
window->setHeight( window->height() - kbRect.height() );
qDebug() << __FUNCTION__ << ":resize-ok-to:" << window->size();
}
}
}
else
{
if ( m_softInputMode == ADJUST_RESIZE && window != 0 && screen != 0 )
{
window->setHeight( screen->size().height() );
qDebug() << __FUNCTION__ << ":resize-ok-to:" << screen->size();
}
window->showNormal();
}
//#endif
#endif
}