本文整理汇总了C++中QWidget::frameGeometry方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::frameGeometry方法的具体用法?C++ QWidget::frameGeometry怎么用?C++ QWidget::frameGeometry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWidget
的用法示例。
在下文中一共展示了QWidget::frameGeometry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: center
void center(QWidget & widget)
{
QRect windowSize = QApplication::desktop() -> frameGeometry();
int x = (windowSize.width() - widget.frameGeometry().width()) / 2;
int y = (windowSize.height() - widget.frameGeometry().height()) / 2;
widget.move(x, y);
}
示例2: grabWindow
QPixmap QPixmap::grabWindow(WId window, int x, int y, int w, int h)
{
QWidget *widget = QWidget::find(window);
if (!widget)
return QPixmap();
QRect grabRect = widget->frameGeometry();
if (!widget->isWindow())
grabRect.translate(widget->parentWidget()->mapToGlobal(QPoint()));
if (w < 0)
w = widget->width() - x;
if (h < 0)
h = widget->height() - y;
grabRect &= QRect(x, y, w, h).translated(widget->mapToGlobal(QPoint()));
QScreen *screen = qt_screen;
QDesktopWidget *desktop = QApplication::desktop();
if (!desktop)
return QPixmap();
if (desktop->numScreens() > 1) {
const int screenNo = desktop->screenNumber(widget);
if (screenNo != -1)
screen = qt_screen->subScreens().at(screenNo);
grabRect = grabRect.translated(-screen->region().boundingRect().topLeft());
}
if (screen->pixelFormat() == QImage::Format_Invalid) {
qWarning("QPixmap::grabWindow(): Unable to copy pixels from framebuffer");
return QPixmap();
}
if (screen->isTransformed()) {
const QSize screenSize(screen->width(), screen->height());
grabRect = screen->mapToDevice(grabRect, screenSize);
}
QWSDisplay::grab(false);
QPixmap pixmap;
QImage img(screen->base(),
screen->deviceWidth(), screen->deviceHeight(),
screen->linestep(), screen->pixelFormat());
img = img.copy(grabRect);
QWSDisplay::ungrab();
if (screen->isTransformed()) {
QMatrix matrix;
switch (screen->transformOrientation()) {
case 1: matrix.rotate(90); break;
case 2: matrix.rotate(180); break;
case 3: matrix.rotate(270); break;
default: break;
}
img = img.transformed(matrix);
}
if (screen->pixelType() == QScreen::BGRPixel)
img = img.rgbSwapped();
return QPixmap::fromImage(img);
}
示例3: handleMousePressEvent
void NcWidgetData::handleMousePressEvent( QMouseEvent* event )
{
if ( event->button() == Qt::LeftButton )
{
mLeftButtonPressed = true;
QRect frameRect = mWidget->frameGeometry();
mPressedMousePos.recalculate( event->globalPos(), frameRect );
mDragPos = event->globalPos() - frameRect.topLeft();
if ( mPressedMousePos.onEdges )
{
if ( d->mUseRubberBandOnResize )
{
mRubberBand->setGeometry( frameRect );
mRubberBand->show();
}
}
else if ( d->mUseRubberBandOnMove )
{
mRubberBand->setGeometry( frameRect );
mRubberBand->show();
}
}
}
示例4: transportCurrent
void GlobalSettingsConfig::transportCurrent()
{
QWidget* w = MusEGlobal::muse->transportWindow();
if (!w)
return;
QRect r(w->frameGeometry());
transportX->setValue(r.x());
transportY->setValue(r.y());
}
示例5: offset
/*!
Returns the offset of \a widget in the coordinates of this
window surface.
*/
QPoint QWindowSurface::offset(const QWidget *widget) const
{
QWidget *window = d_ptr->window;
QPoint offset = widget->mapTo(window, QPoint());
#ifdef Q_WS_QWS
offset += window->geometry().topLeft() - window->frameGeometry().topLeft();
#endif
return offset;
}
示例6: childAt
/*! \reimp */
int QAccessibleApplication::childAt(int x, int y) const
{
const QWidgetList tlw(topLevelWidgets());
for (int i = 0; i < tlw.count(); ++i) {
QWidget *w = tlw.at(i);
if (w->frameGeometry().contains(x,y))
return i+1;
}
return -1;
}
示例7: center
void center(QWidget &widget)
{
int x, y;
int screenWidth;
int screenHeight;
QDesktopWidget *desktop = QApplication::desktop();
screenWidth = desktop->width();
screenHeight = desktop->height();
int WIDTH = widget.frameGeometry().width();
int HEIGHT = widget.frameGeometry().height();
x = (screenWidth - WIDTH) / 2;
y = (screenHeight - HEIGHT) / 2;
widget.move(x,y);
// widget.setGeometry(x, y, WIDTH, HEIGHT);
// widget.setFixedSize(WIDTH, HEIGHT);
}
示例8: r
void GlobalSettingsConfig::mixer2Current()
{
QWidget* w = MusEGlobal::muse->mixer2Window();
if (!w)
return;
QRect r(w->frameGeometry());
mixer2X->setValue(r.x());
mixer2Y->setValue(r.y());
mixer2W->setValue(w->width());
mixer2H->setValue(w->height());
}
示例9: bigtimeCurrent
void GlobalSettingsConfig::bigtimeCurrent()
{
QWidget* w = MusEGlobal::muse->bigtimeWindow();
if (!w)
return;
QRect r(w->frameGeometry());
bigtimeX->setValue(r.x());
bigtimeY->setValue(r.y());
bigtimeW->setValue(w->width());
bigtimeH->setValue(w->height());
}
示例10: QSize
QSize
VBoxDbgBaseWindow::vGuessBorderSizes()
{
#ifdef Q_WS_X11 /* (from the qt gui) */
/* only once. */
if (!m_cxBorder && !m_cyBorder)
{
/* On X11, there is no way to determine frame geometry (including WM
* decorations) before the widget is shown for the first time. Stupidly
* enumerate other top level widgets to find the thickest frame. The code
* is based on the idea taken from QDialog::adjustPositionInternal(). */
int extraw = 0, extrah = 0;
QWidgetList list = QApplication::topLevelWidgets();
QListIterator<QWidget*> it (list);
while ((extraw == 0 || extrah == 0) && it.hasNext())
{
int framew, frameh;
QWidget *current = it.next();
if (!current->isVisible())
continue;
framew = current->frameGeometry().width() - current->width();
frameh = current->frameGeometry().height() - current->height();
extraw = qMax (extraw, framew);
extrah = qMax (extrah, frameh);
}
if (extraw || extrah)
{
m_cxBorder = extraw;
m_cyBorder = extrah;
}
}
#endif /* X11 */
return QSize(m_cxBorder, m_cyBorder);
}
示例11: normalizeGeometry
void UIMachineViewNormal::normalizeGeometry(bool bAdjustPosition)
{
#ifndef VBOX_GUI_WITH_CUSTOMIZATIONS1
QWidget *pTopLevelWidget = window();
/* Make no normalizeGeometry in case we are in manual resize mode or main window is maximized: */
if (pTopLevelWidget->isMaximized())
return;
/* Calculate client window offsets: */
QRect frameGeo = pTopLevelWidget->frameGeometry();
QRect geo = pTopLevelWidget->geometry();
int dl = geo.left() - frameGeo.left();
int dt = geo.top() - frameGeo.top();
int dr = frameGeo.right() - geo.right();
int db = frameGeo.bottom() - geo.bottom();
/* Get the best size w/o scroll bars: */
QSize s = pTopLevelWidget->sizeHint();
/* Resize the frame to fit the contents: */
s -= pTopLevelWidget->size();
frameGeo.setRight(frameGeo.right() + s.width());
frameGeo.setBottom(frameGeo.bottom() + s.height());
if (bAdjustPosition)
{
QRegion availableGeo;
QDesktopWidget *dwt = QApplication::desktop();
if (dwt->isVirtualDesktop())
/* Compose complex available region */
for (int i = 0; i < dwt->numScreens(); ++ i)
availableGeo += dwt->availableGeometry(i);
else
/* Get just a simple available rectangle */
availableGeo = dwt->availableGeometry(pTopLevelWidget->pos());
frameGeo = VBoxGlobal::normalizeGeometry(frameGeo, availableGeo, vboxGlobal().vmRenderMode() != SDLMode /* can resize? */);
}
#if 0
/* Center the frame on the desktop: */
frameGeo.moveCenter(availableGeo.center());
#endif
/* Finally, set the frame geometry */
pTopLevelWidget->setGeometry(frameGeo.left() + dl, frameGeo.top() + dt, frameGeo.width() - dl - dr, frameGeo.height() - dt - db);
#else /* !VBOX_GUI_WITH_CUSTOMIZATIONS1 */
Q_UNUSED(bAdjustPosition);
#endif /* VBOX_GUI_WITH_CUSTOMIZATIONS1 */
}
示例12: currentDropLocation
int MovableWidgetContainer::currentDropLocation(const QPoint &p)
{
int drop_location_index = -1;
for (int i = 0; i < layout()->count(); ++i) {
QLayoutItem *item = layout()->itemAt(i);
QWidget *widget = item->widget();
if (widget) {
if (widget->frameGeometry().contains(p)) {
drop_location_index = i;
break;
}
}
}
return drop_location_index;
}
示例13: tickMouse
void TransparentPlugin::tickMouse()
{
#ifdef WIN32
QPoint p = QCursor::pos();
bool bMouse = false;
QWidget *main = getMainWindow();
if (main && main->isVisible()){
if (main->frameGeometry().contains(p))
bMouse = true;
}
if (bMouse != m_bHaveMouse){
m_bHaveMouse = bMouse;
setState();
}
#endif
}
示例14: updateCursorShape
void NcWidgetData::updateCursorShape( const QPoint& globalMousePos )
{
if ( mWidget->isFullScreen() || mWidget->isMaximized() )
{
if ( mCursorShapeChanged )
mWidget->unsetCursor();
return;
}
mMoveMousePos.recalculate( globalMousePos, mWidget->frameGeometry() );
if( mMoveMousePos.onTopLeftEdge || mMoveMousePos.onBottomRightEdge )
{
mWidget->setCursor( Qt::SizeFDiagCursor );
mCursorShapeChanged = true;
}
else if( mMoveMousePos.onTopRightEdge || mMoveMousePos.onBottomLeftEdge )
{
mWidget->setCursor( Qt::SizeBDiagCursor );
mCursorShapeChanged = true;
}
else if( mMoveMousePos.onLeftEdge || mMoveMousePos.onRightEdge )
{
mWidget->setCursor( Qt::SizeHorCursor );
mCursorShapeChanged = true;
}
else if( mMoveMousePos.onTopEdge || mMoveMousePos.onBottomEdge )
{
mWidget->setCursor( Qt::SizeVerCursor );
mCursorShapeChanged = true;
}
else
{
if ( mCursorShapeChanged )
{
mWidget->unsetCursor();
mCursorShapeChanged = false;
}
}
}
示例15: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget widget;
widget.resize(400, 300); //设置窗口大小
widget.move(200, 100); //设置窗口位置
widget.show();
int x = widget.x();
qDebug("x: %d", x); //输出x的值
int y = widget.y();
qDebug("y: %d", y);
QRect geometry = widget.geometry();
QRect frame = widget.frameGeometry();
qDebug() << "geometry: " << geometry << "frame: " << frame;
qDebug() << "pos:" << widget.pos() << endl << "rect:" << widget.rect()
<< endl << "size:" << widget.size() << endl << "width:"
<< widget.width() << endl << "height:" << widget.height();
return a.exec();
}