当前位置: 首页>>代码示例>>C++>>正文


C++ QWidget::frameGeometry方法代码示例

本文整理汇总了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);
}
开发者ID:GustavoARod,项目名称:the-soda-dispenser,代码行数:9,代码来源:main.cpp

示例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);
}
开发者ID:,项目名称:,代码行数:60,代码来源:

示例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();
    }

  }
}
开发者ID:307509256,项目名称:Bull-Live-Encoder,代码行数:27,代码来源:NcFramelessHelper.cpp

示例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());
      }
开发者ID:falkTX,项目名称:muse,代码行数:9,代码来源:genset.cpp

示例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;
}
开发者ID:cdaffara,项目名称:symbiandump-mw3,代码行数:13,代码来源:qwindowsurface.cpp

示例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;
}
开发者ID:AtlantisCD9,项目名称:Qt,代码行数:11,代码来源:qaccessibleobject.cpp

示例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);
}
开发者ID:tuxdna,项目名称:sourcecode,代码行数:20,代码来源:main.cpp

示例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());
      }
开发者ID:falkTX,项目名称:muse,代码行数:11,代码来源:genset.cpp

示例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());
      }
开发者ID:falkTX,项目名称:muse,代码行数:11,代码来源:genset.cpp

示例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);
}
开发者ID:bhanug,项目名称:virtualbox,代码行数:40,代码来源:VBoxDbgBase.cpp

示例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 */
}
开发者ID:,项目名称:,代码行数:52,代码来源:

示例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;
}
开发者ID:Sektorka,项目名称:ocs,代码行数:15,代码来源:movablewidgetcontainer.cpp

示例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
}
开发者ID:,项目名称:,代码行数:16,代码来源:

示例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;
    }
  }
}
开发者ID:307509256,项目名称:Bull-Live-Encoder,代码行数:41,代码来源:NcFramelessHelper.cpp

示例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();
}
开发者ID:ifhw,项目名称:study,代码行数:22,代码来源:main.cpp


注:本文中的QWidget::frameGeometry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。