• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ QRect函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中QRect函数的典型用法代码示例。如果您正苦于以下问题:C++ QRect函数的具体用法?C++ QRect怎么用?C++ QRect使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了QRect函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: QPoint

void RenderArea::paintEvent(QPaintEvent *)
{
    static const QPoint points[4] = {
        QPoint(10, 80),
        QPoint(20, 10),
        QPoint(80, 30),
        QPoint(90, 70)
    };

    QRect rect(10, 20, 80, 60);

    QPainterPath path;
    path.moveTo(20, 80);
    path.lineTo(20, 30);
    path.cubicTo(80, 0, 50, 50, 80, 80);

    int startAngle = 20 * 16;
    int arcLength = 120 * 16;

    QPainter painter(this);
    painter.setPen(pen);
    painter.setBrush(brush);
    if (antialiased)
        painter.setRenderHint(QPainter::Antialiasing, true);

    for (int x = 0; x < width(); x += 100)
    {
        for (int y = 0; y < height(); y += 100)
        {
            painter.save();
            painter.translate(x, y);

            if (transformed) {
                painter.translate(50, 50);
                painter.rotate(60.0);
                painter.scale(0.6, 0.9);
                painter.translate(-50, -50);
            }

            switch (shape) {
            case Line:
                painter.drawLine(rect.bottomLeft(), rect.topRight());
                break;
            case Points:
                painter.drawPoints(points, 4);
                break;
            case Polyline:
                painter.drawPolyline(points, 4);
                break;
            case Polygon:
                painter.drawPolygon(points, 4);
                break;
            case Rect:
                painter.drawRect(rect);
                break;
            case RoundedRect:
                painter.drawRoundedRect(rect, 25, 25, Qt::RelativeSize);
                break;
            case Ellipse:
                painter.drawEllipse(rect);
                break;
            case Arc:
                painter.drawArc(rect, startAngle, arcLength);
                break;
            case Chord:
                painter.drawChord(rect, startAngle, arcLength);
                break;
            case Pie:
                painter.drawPie(rect, startAngle, arcLength);
                break;
            case Path:
                painter.drawPath(path);
                break;
            case Text:
                painter.drawText(rect, Qt::AlignCenter, tr("Qt by\nDigia"));
                break;
            case Pixmap:
                painter.drawPixmap(10, 10, pixmap);
            } // end switch

            painter.restore();
        } // end for
    } // end for

    painter.setRenderHint(QPainter::Antialiasing, false);
    painter.setPen(palette().dark().color());
    painter.setBrush(Qt::NoBrush);
    painter.drawRect(QRect(0, 0, width() - 1, height() - 1));
}
开发者ID:qidaizhe11,项目名称:My-Qt-learning,代码行数:89,代码来源:renderarea.cpp


示例2: QRect

void tst_QItemDelegate::editorEvent_data()
{
    QTest::addColumn<QRect>("rect");
    QTest::addColumn<QString>("text");
    QTest::addColumn<int>("checkState");
    QTest::addColumn<int>("flags");
    QTest::addColumn<bool>("inCheck");
    QTest::addColumn<int>("type");
    QTest::addColumn<int>("button");
    QTest::addColumn<bool>("edited");
    QTest::addColumn<int>("expectedCheckState");

    QTest::newRow("unchecked, checkable, release")
        << QRect(0, 0, 20, 20)
        << QString("foo")
        << (int)(Qt::Unchecked)
        << (int)(Qt::ItemIsEditable
            |Qt::ItemIsSelectable
            |Qt::ItemIsUserCheckable
            |Qt::ItemIsEnabled
            |Qt::ItemIsDragEnabled
            |Qt::ItemIsDropEnabled)
        << true
        << (int)(QEvent::MouseButtonRelease)
        << (int)(Qt::LeftButton)
        << true
        << (int)(Qt::Checked);

    QTest::newRow("checked, checkable, release")
        << QRect(0, 0, 20, 20)
        << QString("foo")
        << (int)(Qt::Checked)
        << (int)(Qt::ItemIsEditable
            |Qt::ItemIsSelectable
            |Qt::ItemIsUserCheckable
            |Qt::ItemIsEnabled
            |Qt::ItemIsDragEnabled
            |Qt::ItemIsDropEnabled)
        << true
        << (int)(QEvent::MouseButtonRelease)
        << (int)(Qt::LeftButton)
        << true
        << (int)(Qt::Unchecked);

    QTest::newRow("unchecked, checkable, release")
        << QRect(0, 0, 20, 20)
        << QString("foo")
        << (int)(Qt::Unchecked)
        << (int)(Qt::ItemIsEditable
            |Qt::ItemIsSelectable
            |Qt::ItemIsUserCheckable
            |Qt::ItemIsEnabled
            |Qt::ItemIsDragEnabled
            |Qt::ItemIsDropEnabled)
        << true
        << (int)(QEvent::MouseButtonRelease)
        << (int)(Qt::LeftButton)
        << true
        << (int)(Qt::Checked);

    QTest::newRow("unchecked, checkable, release, right button")
        << QRect(0, 0, 20, 20)
        << QString("foo")
        << (int)(Qt::Unchecked)
        << (int)(Qt::ItemIsEditable
            |Qt::ItemIsSelectable
            |Qt::ItemIsUserCheckable
            |Qt::ItemIsEnabled
            |Qt::ItemIsDragEnabled
            |Qt::ItemIsDropEnabled)
        << true
        << (int)(QEvent::MouseButtonRelease)
        << (int)(Qt::RightButton)
        << false
        << (int)(Qt::Unchecked);

    QTest::newRow("unchecked, checkable, release outside")
        << QRect(0, 0, 20, 20)
        << QString("foo")
        << (int)(Qt::Unchecked)
        << (int)(Qt::ItemIsEditable
            |Qt::ItemIsSelectable
            |Qt::ItemIsUserCheckable
            |Qt::ItemIsEnabled
            |Qt::ItemIsDragEnabled
            |Qt::ItemIsDropEnabled)
        << false
        << (int)(QEvent::MouseButtonRelease)
        << (int)(Qt::LeftButton)
        << false
        << (int)(Qt::Unchecked);

    QTest::newRow("unchecked, checkable, dblclick")
        << QRect(0, 0, 20, 20)
        << QString("foo")
        << (int)(Qt::Unchecked)
        << (int)(Qt::ItemIsEditable
            |Qt::ItemIsSelectable
            |Qt::ItemIsUserCheckable
            |Qt::ItemIsEnabled
//.........这里部分代码省略.........
开发者ID:crobertd,项目名称:qtbase,代码行数:101,代码来源:tst_qitemdelegate.cpp


示例3: r

void SessionsInner::paintEvent(QPaintEvent *e) {
    QRect r(e->rect());
    Painter p(this);

    p.fillRect(r, st::white->b);
    int32 x = st::sessionPadding.left(), xact = st::sessionTerminateSkip + st::sessionTerminate.iconPos.x();// st::sessionTerminateSkip + st::sessionTerminate.width + st::sessionTerminateSkip;
    int32 w = width();

    if (_current->active.isEmpty() && _list->isEmpty()) {
        p.setFont(st::noContactsFont->f);
        p.setPen(st::noContactsColor->p);
        p.drawText(QRect(0, 0, width(), st::noContactsHeight), lang(lng_contacts_loading), style::al_center);
        return;
    }

    if (r.y() <= st::sessionCurrentHeight) {
        p.translate(0, st::sessionCurrentPadding.top());
        p.setFont(st::sessionNameFont->f);
        p.setPen(st::black->p);
        p.drawTextLeft(x, st::sessionPadding.top(), w, _current->name, _current->nameWidth);

        p.setFont(st::sessionActiveFont->f);
        p.setPen(st::sessionActiveColor->p);
        p.drawTextRight(x, st::sessionPadding.top(), w, _current->active, _current->activeWidth);

        p.setFont(st::sessionInfoFont->f);
        p.setPen(st::black->p);
        p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, _current->info, _current->infoWidth);
        p.setPen(st::sessionInfoColor->p);
        p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, _current->ip, _current->ipWidth);
    }
    p.translate(0, st::sessionCurrentHeight - st::sessionCurrentPadding.top());
    if (_list->isEmpty()) {
        p.setFont(st::sessionInfoFont->f);
        p.setPen(st::sessionInfoColor->p);
        p.drawText(QRect(st::sessionPadding.left(), 0, width() - st::sessionPadding.left() - st::sessionPadding.right(), st::noContactsHeight), lang(lng_sessions_other_desc), style::al_topleft);
        return;
    }

    p.setFont(st::linkFont->f);
    int32 count = _list->size();
    int32 from = floorclamp(r.y() - st::sessionCurrentHeight, st::sessionHeight, 0, count);
    int32 to = ceilclamp(r.y() + r.height() - st::sessionCurrentHeight, st::sessionHeight, 0, count);
    p.translate(0, from * st::sessionHeight);
    for (int32 i = from; i < to; ++i) {
        const SessionData &auth(_list->at(i));

        p.setFont(st::sessionNameFont->f);
        p.setPen(st::black->p);
        p.drawTextLeft(x, st::sessionPadding.top(), w, auth.name, auth.nameWidth);

        p.setFont(st::sessionActiveFont->f);
        p.setPen(st::sessionActiveColor->p);
        p.drawTextRight(xact, st::sessionPadding.top(), w, auth.active, auth.activeWidth);

        p.setFont(st::sessionInfoFont->f);
        p.setPen(st::black->p);
        p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height, w, auth.info, auth.infoWidth);
        p.setPen(st::sessionInfoColor->p);
        p.drawTextLeft(x, st::sessionPadding.top() + st::sessionNameFont->height + st::sessionInfoFont->height, w, auth.ip, auth.ipWidth);

        p.translate(0, st::sessionHeight);
    }
}
开发者ID:neuroidss,项目名称:tdesktop,代码行数:64,代码来源:sessionsbox.cpp


示例4: readSettings


//.........这里部分代码省略.........
            paint.fillRect( 0, maxHeight+innerMargin, headerWidth, boxWidth, boxColor );
        }

        if ( useGuide && currentPage == 1 )
        {  // FIXME - this may span more pages...
          // draw a box unless we have boxes, in which case we end with a box line
          int _ystart = y;
          QString _hlName = doc->highlight()->name();

          QList<KateExtendedAttribute::Ptr> _attributes; // list of highlight attributes for the legend
          doc->highlight()->getKateExtendedAttributeList(kpl->colorScheme(), _attributes);

          KateAttributeList _defaultAttributes;
          KateHlManager::self()->getDefaults ( renderer.config()->schema(), _defaultAttributes );

          QColor _defaultPen = _defaultAttributes.at(0)->foreground().color();
          paint.setPen(_defaultPen);

          int _marg = 0;
          if ( useBox )
            _marg += (2*boxWidth) + (2*innerMargin);
          else
          {
            if ( useBackground )
              _marg += 2*innerMargin;
            _marg += 1;
            y += 1 + innerMargin;
          }

          // draw a title string
          QFont _titleFont = renderer.config()->font();
          _titleFont.setBold(true);
          paint.setFont( _titleFont );
          QRect _r;
          paint.drawText( QRect(_marg, y, pdmWidth-(2*_marg), maxHeight - y),
            Qt::AlignTop|Qt::AlignHCenter,
            i18n("Typographical Conventions for %1", _hlName ), &_r );
          int _w = pdmWidth - (_marg*2) - (innerMargin*2);
          int _x = _marg + innerMargin;
          y += _r.height() + innerMargin;
          paint.drawLine( _x, y, _x + _w, y );
          y += 1 + innerMargin;

          int _widest( 0 );
          foreach (const KateExtendedAttribute::Ptr &attribute, _attributes)
            _widest = qMax(QFontMetrics(attribute->font()).width(attribute->name().section(':',1,1)), _widest);

          int _guideCols = _w/( _widest + innerMargin );

          // draw attrib names using their styles
          int _cw = _w/_guideCols;
          int _i(0);

          _titleFont.setUnderline(true);
          QString _currentHlName;
          foreach (const KateExtendedAttribute::Ptr &attribute, _attributes)
          {
            QString _hl = attribute->name().section(':',0,0);
            QString _name = attribute->name().section(':',1,1);
            if ( _hl != _hlName && _hl != _currentHlName ) {
              _currentHlName = _hl;
              if ( _i%_guideCols )
                y += fontHeight;
              y += innerMargin;
              paint.setFont(_titleFont);
              paint.setPen(_defaultPen);
开发者ID:UIKit0,项目名称:kate,代码行数:67,代码来源:kateprinter.cpp


示例5: qWarning

void FancyTabBar::paintTab(QPainter *painter, int tabIndex) const
{
    if (!validIndex(tabIndex)) {
        qWarning("invalid index");
        return;
    }
    painter->save();

    QRect rect = tabRect(tabIndex);
    bool selected = (tabIndex == m_currentIndex);
    bool enabled = isTabEnabled(tabIndex);

    if (selected) {
        //background
        painter->save();
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, QColor(255, 255, 255, 140));
        grad.setColorAt(1, QColor(255, 255, 255, 210));
        painter->fillRect(rect.adjusted(0, 0, 0, -1), grad);
        painter->restore();

        //shadows
        painter->setPen(QColor(0, 0, 0, 110));
        painter->drawLine(rect.topLeft() + QPoint(1,-1), rect.topRight() - QPoint(0,1));
        painter->drawLine(rect.bottomLeft(), rect.bottomRight());
        painter->setPen(QColor(0, 0, 0, 40));
        painter->drawLine(rect.topLeft(), rect.bottomLeft());

        //highlights
        painter->setPen(QColor(255, 255, 255, 50));
        painter->drawLine(rect.topLeft() + QPoint(0, -2), rect.topRight() - QPoint(0,2));
        painter->drawLine(rect.bottomLeft() + QPoint(0, 1), rect.bottomRight() + QPoint(0,1));
        painter->setPen(QColor(255, 255, 255, 40));
        painter->drawLine(rect.topLeft() + QPoint(0, 0), rect.topRight());
        painter->drawLine(rect.topRight() + QPoint(0, 1), rect.bottomRight() - QPoint(0, 1));
        painter->drawLine(rect.bottomLeft() + QPoint(0,-1), rect.bottomRight()-QPoint(0,1));
    }

    QString tabText(this->tabText(tabIndex));
    QRect tabTextRect(rect);
    const bool drawIcon = rect.height() > 36;
    QRect tabIconRect(tabTextRect);
    tabTextRect.translate(0, drawIcon ? -2 : 1);
    QFont boldFont(painter->font());
    boldFont.setPointSizeF(StyleHelper::sidebarFontSize());
    boldFont.setBold(true);
    painter->setFont(boldFont);
    painter->setPen(selected ? QColor(255, 255, 255, 160) : QColor(0, 0, 0, 110));
    const int textFlags = Qt::AlignCenter | (drawIcon ? Qt::AlignBottom : Qt::AlignVCenter) | Qt::TextWordWrap;
    if (enabled) {
        painter->drawText(tabTextRect, textFlags, tabText);
        painter->setPen(selected ? QColor(60, 60, 60) : StyleHelper::panelTextColor());
    } else {
        painter->setPen(selected ? StyleHelper::panelTextColor() : QColor(255, 255, 255, 120));
    }
    if (/*!Utils::HostOsInfo::isMacHost()*/ true && !selected && enabled) {
        painter->save();
        int fader = int(m_tabs[tabIndex]->fader());
        QLinearGradient grad(rect.topLeft(), rect.topRight());
        grad.setColorAt(0, Qt::transparent);
        grad.setColorAt(0.5, QColor(255, 255, 255, fader));
        grad.setColorAt(1, Qt::transparent);
        painter->fillRect(rect, grad);
        painter->setPen(QPen(grad, 1.0));
        painter->drawLine(rect.topLeft(), rect.topRight());
        painter->drawLine(rect.bottomLeft(), rect.bottomRight());
        painter->restore();
    }

    if (!enabled)
        painter->setOpacity(0.7);

    if (drawIcon) {
        int textHeight = painter->fontMetrics().boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, tabText).height();
        tabIconRect.adjust(0, 4, 0, -textHeight);
        StyleHelper::drawIconWithShadow(tabIcon(tabIndex), tabIconRect, painter, enabled ? QIcon::Normal : QIcon::Disabled);
    }

    painter->translate(0, -1);
    painter->drawText(tabTextRect, textFlags, tabText);
    painter->restore();
}
开发者ID:innoink,项目名称:SiftFaceRec,代码行数:82,代码来源:fancytabwidget.cpp


示例6: int

void SelectionView::mousePressEvent( QMouseEvent *e )
{
    if ( _drawLine ) {
        _drawLineHold = true;
        delete linePath;
        linePath = new QPainterPath;
        linePath->moveTo( e->posF() );
        e->accept();
        return;
    }

	//add
	QPoint expandingTopLeft;
	QPoint expandingTerminalPoint;

	int expandingWidth  = int(_snapWidth*_zoomRatio*(_expandingWidthRatio-1)*0.5)+_expandingWidth*_zoomRatio;
	int expandingHeight = int(_snapHeight*_zoomRatio*(_expandingHeightRatio-1)*0.5)+_expandingHeight*_zoomRatio;

	//add
	_selectionFinished = false;

	_originPoint = e->pos();

	// !* selfDefine selection, draw a rectangle with size of given pixel.
	if (_snapRatio == -1.0)
	{
		//!* from center
		if (_isFromCenter)
		{
			_pCenterRubberBand->show();
			_pCenterRubberBand->setGeometry(QRect(_originPoint-QPoint(3,3), _originPoint+QPoint(3,3)).normalized());
			_pRubberBand->setGeometry( _originPoint.x() - int(_snapWidth*_zoomRatio/2),	
				_originPoint.y() - int(_snapHeight*_zoomRatio/2), 
				_snapWidth*_zoomRatio, _snapHeight*_zoomRatio);	
			_pExpandingRubberBand->setGeometry( _originPoint.x() - int(_snapWidth*_zoomRatio/2) - expandingWidth,	
				_originPoint.y() - int(_snapHeight*_zoomRatio/2) - expandingWidth, 
				_snapWidth*_zoomRatio + expandingWidth*2, _snapHeight*_zoomRatio + expandingWidth*2);	
		}
		//!* from TopLeft
		else
		{
			_pCenterRubberBand->hide();
			_pRubberBand->setGeometry( _originPoint.x(), _originPoint.y(), 
				_snapWidth*_zoomRatio-1, _snapHeight*_zoomRatio-1);	
			_pExpandingRubberBand->setGeometry( _originPoint.x() - expandingWidth, _originPoint.y() - expandingWidth, 
				_snapWidth*_zoomRatio-1 + expandingWidth*2, _snapHeight*_zoomRatio-1 + expandingWidth*2);	
		}
	}
	else
	{
		//!* from center
		if (_isFromCenter)
		{
			_pCenterRubberBand->show();
			_pCenterRubberBand->setGeometry(QRect(_originPoint-QPoint(3,3), _originPoint+QPoint(3,3)).normalized());
		}
		else
			_pCenterRubberBand->hide();
		_pRubberBand->setGeometry(QRect(_originPoint, QSize()));
		_pExpandingRubberBand->setGeometry(QRect(_originPoint, QSize()));
	}

	_pExpandingRubberBand->show();
	_pRubberBand->show();
}	
开发者ID:BenJamesbabala,项目名称:SignProcessing,代码行数:65,代码来源:SelectionView.cpp


示例7: titleBarHeight

/*!
  Returns the region specified by \a decorationRegion for the
  top-level \a widget. \a rect specifies the rectangle the decoration
  wraps. The value of \a decorationRegion is a combination of the
  bitmask values of enum DecorationRegion.
 */
QRegion QDecorationDefault::region(const QWidget *widget,
                                   const QRect &rect,
                                   int decorationRegion)
{
    Qt::WindowFlags flags = widget->windowFlags();
    bool hasBorder = !widget->isMaximized();
    bool hasTitle = flags & Qt::WindowTitleHint;
    bool hasSysMenu = flags & Qt::WindowSystemMenuHint;
    bool hasContextHelp = flags & Qt::WindowContextHelpButtonHint;
    bool hasMinimize = flags & Qt::WindowMinimizeButtonHint;
    bool hasMaximize = flags & Qt::WindowMaximizeButtonHint;
    int state = widget->windowState();
    bool isMinimized = state & Qt::WindowMinimized;
    bool isMaximized = state & Qt::WindowMaximized;

    int titleHeight = hasTitle ? titleBarHeight(widget) : 0;
    int bw = hasBorder ? BORDER_WIDTH : 0;
    int bbw = hasBorder ? BOTTOM_BORDER_WIDTH : 0;

    QRegion region;
    switch (decorationRegion) {
        case All: {
                QRect r(rect.left() - bw,
                        rect.top() - titleHeight - bw,
                        rect.width() + 2 * bw,
                        rect.height() + titleHeight + bw + bbw);
                region = r;
                region -= rect;
            }
            break;

        case Title: {
                QRect r(rect.left()
                        + (hasSysMenu ? menu_width : 0),
                        rect.top() - titleHeight,
                        rect.width()
                        - (hasSysMenu ? menu_width : 0)
                        - close_width
                        - (hasMaximize ? maximize_width : 0)
                        - (hasMinimize ? minimize_width : 0)
                        - (hasContextHelp ? help_width : 0),

                        titleHeight);
                if (r.width() > 0)
                    region = r;
            }
            break;

        case Top: {
                QRect r(rect.left() + CORNER_GRAB,
                        rect.top() - titleHeight - bw,
                        rect.width() - 2 * CORNER_GRAB,
                        bw);
                region = r;
            }
            break;

        case Left: {
                QRect r(rect.left() - bw,
                        rect.top() - titleHeight + CORNER_GRAB,
                        bw,
                        rect.height() + titleHeight - 2 * CORNER_GRAB);
                region = r;
            }
            break;

        case Right: {
                QRect r(rect.right() + 1,
                        rect.top() - titleHeight + CORNER_GRAB,
                        bw,
                        rect.height() + titleHeight - 2 * CORNER_GRAB);
                region = r;
            }
            break;

        case Bottom: {
                QRect r(rect.left() + CORNER_GRAB,
                        rect.bottom() + 1,
                        rect.width() - 2 * CORNER_GRAB,
                        bw);
                region = r;
            }
            break;

        case TopLeft: {
                QRect r1(rect.left() - bw,
                        rect.top() - bw - titleHeight,
                        CORNER_GRAB + bw,
                        bw);

                QRect r2(rect.left() - bw,
                        rect.top() - bw - titleHeight,
                        bw,
                        CORNER_GRAB + bw);
//.........这里部分代码省略.........
开发者ID:cdaffara,项目名称:symbiandump-mw3,代码行数:101,代码来源:qdecorationdefault_qws.cpp


示例8: shrinkRectToSquare

static inline QRect shrinkRectToSquare(const QRect& rect)
{
    const int side = qMin(rect.height(), rect.width());
    return QRect(rect.topLeft(), QSize(side, side));
}
开发者ID:ruizhang331,项目名称:WebKit,代码行数:5,代码来源:RenderThemeQtMobile.cpp


示例9: contentsRect

void CodeEditor::resizeEvent(QResizeEvent *e) {
    QPlainTextEdit::resizeEvent(e);

    QRect cr = contentsRect();
    lineNumberArea->setGeometry(QRect(cr.left(), cr.top(), lineNumberAreaWidth(), cr.height()));
}
开发者ID:flamingoen,项目名称:qspin,代码行数:6,代码来源:codeeditor.cpp


示例10: doLayout

int FlowLayout::heightForWidth(int width) const
{
    int height = doLayout(QRect(0, 0, width, 0), true);
    return height;
}
开发者ID:DaveDubUK,项目名称:hifi,代码行数:5,代码来源:FlowLayout.cpp


示例11: setGeometry

void CGadgetListBar::QuickCloseBar(void)
{
	setGeometry(QRect(FRAME_START_X, FRAME_START_Y, FRAME_WIDTH, FRAME_HEIGHT));
}
开发者ID:bravesheng,项目名称:offroad-navi,代码行数:4,代码来源:GadgetListBar.cpp


示例12: QFont

void googleweatherWidget::drawSet(QPainter *p)
{
    QString current,humidity,temp,wind,image,curr_date;
    current = weatherValues.at(0);
    humidity = weatherValues.at(1);
    temp = weatherValues.at(2);
    wind = weatherValues.at(3);
    curr_date = weatherValues.at(25);
    QStringList f_day,f_condition,f_lTemp,f_hTemp,f_image;

    f_day<<weatherValues.at(4)<<weatherValues.at(5)<<weatherValues.at(6)<<weatherValues.at(7);
    f_condition<<weatherValues.at(8)<<weatherValues.at(9)<<weatherValues.at(10)<<weatherValues.at(11);
    f_lTemp<<weatherValues.at(12)<<weatherValues.at(13)<<weatherValues.at(14)<<weatherValues.at(15);
    f_hTemp<<weatherValues.at(16)<<weatherValues.at(17)<<weatherValues.at(18)<<weatherValues.at(19);
    f_image<<weatherValues.at(21)<<weatherValues.at(22)<<weatherValues.at(23)<<weatherValues.at(24);
    image = weatherValues.at(20);


    p->setPen(QColor(255,255,255,255));
    p->setFont(QFont("SansSerif", 15, QFont::Bold));
    p->drawLine(clip.x()+w_ImageDock.width()+57,view.y()+45,clip.x()+w_ImageDock.width()+251,view.y()+45);
    p->drawText(clip.x()+w_ImageDock.width()+60, view.y()+40, "Google Weather");
    p->setPen(QColor(0,255,255,127));
    p->setFont(QFont("SansSerif", 10, QFont::Normal));
    if (current != "Data not recieved")
    {
        p->drawText(clip.x()+10, view.y()+65, "City: Colombo");
        p->setPen(QColor(200,255,100,127));

        //------------current conditions --------------
        QFont tempFont = QFont("OldEnglish", 14, QFont::DemiBold);
        tempFont.setStyleStrategy(QFont::OpenGLCompatible);
        p->setFont(tempFont);
        p->drawText(clip.x()+20, view.y()+155,current);
        p->setFont(QFont("SansSerif", 10, QFont::Normal));
        p->setPen(QColor(58,136,253));
        p->drawText(clip.x()+250, view.y()+90,"Today : " + curr_date);
        p->drawText(clip.x()+250, view.y()+130, humidity);
        p->drawText(clip.x()+250, view.y()+145,wind);
        tempInCel(p,temp,10,120,true,35);
        p->drawImage(QRect(clip.x()+140,view.y()+55,100,100),QImage(prefix+image+".png"));
        //-----------end of current conditions-----------

        //////////////// forecst information //////////////////////

        p->setFont(QFont("SansSerif", 10, QFont::Normal));
        p->setPen(QColor(50,50,50));
        p->drawLine(clip.x()+5,view.y()+175,clip.x()+402,view.y()+175);
        p->drawLine(clip.x()+140,view.y()+175,clip.x()+140,view.y()+270);
        p->drawLine(clip.x()+270,view.y()+175,clip.x()+270,view.y()+270);
        for (int i=1;i<4;i++)
        {
            p->setPen(QColor(0,234,255));
            p->drawText(clip.x()+15+(i-1)*130, view.y()+190, getDay(f_day.at(i)));
            p->setPen(QColor(56,193,124));
            p->drawText(clip.x()+15+(i-1)*130, view.y()+267,f_condition.at(i));
            p->setFont(QFont("SansSerif", 6, QFont::Normal));
            p->drawText(clip.x()+15+(i-1)*130,view.y()+280,"Lowest");            
            tempInCel(p,f_lTemp.at(i),15+(i-1)*130,300,false,12);
            p->setFont(QFont("SansSerif", 6, QFont::Normal));
            p->setPen(QColor(56,193,124));
            p->drawText(clip.x()+70+(i-1)*130,view.y()+280,"Highest");            
            tempInCel(p,f_hTemp.at(i),70+(i-1)*130,300,false,10);
            p->drawImage(QRect(clip.x()+20+(i-1)*130,view.y()+200,50,50),QImage(prefix+f_image.at(i)+".png"));
        }

        ///////////////// forecast information ///////////////////////
    }
    else
    {
        p->setPen(QColor(255,18,18,127));
        p->drawText(clip.x()+40,view.y()+85, "--Error----");
        p->setPen(QColor(24,200,198,127));
        p->drawText(clip.x()+40,view.y()+100, "Check network connection.");
        p->drawText(clip.x()+40,view.y()+115, "could not establish connection with google.");
        p->drawText(clip.x()+40,view.y()+130, "If problem persist, contact plexydesk dev team.");
        p->drawText(clip.x()+40,view.y()+145, "Online help available in IRC channel #plexydesk .");
        p->setPen(QColor(255,18,18,127));
        p->drawText(clip.x()+40,view.y()+160, "----------");

    }


}
开发者ID:varuna,项目名称:Social_plexydesk,代码行数:84,代码来源:googleweatherwidget.cpp


示例13: parentTree

QRect QITreeViewItem::rect() const
{
    /* Redirect call to parent-tree: */
    return parentTree() ? parentTree()->visualRect(modelIndex()) : QRect();
}
开发者ID:mdaniel,项目名称:virtualbox-org-svn-vbox-trunk,代码行数:5,代码来源:QITreeView.cpp


示例14: Q_UNUSED

// Resets hover animation on mouse enter
void FancyTabBar::enterEvent(QEvent *e)
{
    Q_UNUSED(e)
    m_hoverRect = QRect();
    m_hoverIndex = -1;
}
开发者ID:innoink,项目名称:SiftFaceRec,代码行数:7,代码来源:fancytabwidget.cpp


示例15: QGraphicsView

Board::Board(QWidget *parent) :
    QGraphicsView(parent)
{
    scene = new QGraphicsScene(QRect(0, 0, 640, 360), this);

    scene->setBackgroundBrush(QBrush(bg));

    ball = scene->addRect(-6, -6, 12, 12, QPen(Qt::SolidLine), QBrush(fg));
    ball->setPos(Width/2-6, Height/2-6);

    // why is y -1...otherwise we have a gap...
    topWall = scene->addRect(0, -1, Width, 12, QPen(Qt::SolidLine), QBrush(fg));
    bottomWall = scene->addRect(0, Height-12, Width, 12, QPen(Qt::SolidLine), QBrush(fg));

    leftPaddle = scene->addRect(0, 12, 12, Paddle, QPen(Qt::SolidLine), QBrush(fg));
    rightPaddle = scene->addRect(Width-12, 12, 12, Paddle, QPen(Qt::SolidLine), QBrush(fg));

    QPen p;
    p.setWidth(2);
    p.setStyle(Qt::DotLine);
    p.setBrush(QBrush(fg));
    scene->addLine(Width/2, 0, Width/2, Height, p);

    QFont f;
    f.setStyleHint(QFont::OldEnglish);
    f.setPixelSize(50);
    f.setBold(true);
    leftScore = scene->addText(QString("0"), f);
    leftScore->setDefaultTextColor(fg);
//    leftScore->setPos(120, 50);

    rightScore = scene->addText(QString("0"), f);
//    rightScore->setPos(Width-140, 50);
    rightScore->setDefaultTextColor(fg);
    setScore(0, 0);

    f.setPixelSize(25);
    status = scene->addText(QString(), f);
    status->setDefaultTextColor(fg);

    ball->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    leftPaddle->setCacheMode(QGraphicsItem::DeviceCoordinateCache);
    rightPaddle->setCacheMode(QGraphicsItem::DeviceCoordinateCache);

    icon.load(QString(":/icons/connect.png"));
    icon = icon.scaled(100, 100, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
    qDebug() << "icon" << icon.isNull();
    connectIcon = scene->addPixmap(icon);
    connectIcon->setPos(440,200);
    connectIcon->setAcceptTouchEvents(true);
    connectIcon->setTransformOriginPoint(50,50);
    connectIcon->setTransformationMode(Qt::SmoothTransformation);

    connectAnimation = new QPropertyAnimation(this, "connectRotation");
    connectAnimation->setDuration(1000);
    connectAnimation->setLoopCount(-1);
    connectAnimation->setStartValue(0);
    connectAnimation->setEndValue(360);

    setCacheMode(QGraphicsView::CacheBackground);
    setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate);

//    connect(scene, SIGNAL(changed(QList<QRectF>)), this, SLOT(sceneChanged(QList<QRectF>)));

}
开发者ID:lainwir3d,项目名称:qtconnectivity,代码行数:65,代码来源:board.cpp


示例16: switch

void SelectionView::keyPressEvent( QKeyEvent *e )
{
	if (_selectionFinished == true)
	{
		switch (e->key())
		{
		case Qt::Key_Space:
			{
				e->accept();
				emit cutoutSelectedRectangle();
				break;
			}

		case Qt::Key_Up:
			{
				_pCenterRubberBand->hide();
				_pRubberBand->hide();
				_pExpandingRubberBand->hide();
				e->accept();
				_originPoint.ry() = _originPoint.y()-1;
				_terminalPoint.ry() = _terminalPoint.y()-1;

				if (_isFromCenter)
				{

					QPoint center;
					center.rx() = _originPoint.x() + (_terminalPoint.x()-_originPoint.x())*0.5;
					center.ry() = _originPoint.y() + (_terminalPoint.y()-_originPoint.y())*0.5;

					//add
					QPoint expandingTopLeft;
					QPoint expandingTerminalPoint;

					int expandingWidth  = int(_pRubberBand->width()*(_expandingWidthRatio-1)*0.5)+_expandingWidth*_zoomRatio;
					int expandingHeight = int(_pRubberBand->height()*(_expandingHeightRatio-1)*0.5)+_expandingHeight*_zoomRatio;

					//expandingTopLeft.rx() = _originPoint.x()-expandingWidth;
					//expandingTopLeft.ry() = _originPoint.y()-expandingHeight;
					//expandingTerminalPoint.rx() = _terminalPoint.x()+expandingWidth;
					//expandingTerminalPoint.ry() = _terminalPoint.y()+expandingHeight;

					//add
					if ((_originPoint.x()-_terminalPoint.x())*(_originPoint.y()-_terminalPoint.y())<0)
					{
						int y;
						y = _originPoint.y();
						_originPoint.ry() = _terminalPoint.y();
						_terminalPoint.ry() = y;
					
					}

					if (_originPoint.x()<_terminalPoint.x())
					{
						expandingTopLeft.rx() = _originPoint.x()-expandingWidth;
						expandingTopLeft.ry() = _originPoint.y()-expandingHeight;
						expandingTerminalPoint.rx() = _terminalPoint.x()+expandingWidth;
						expandingTerminalPoint.ry() = _terminalPoint.y()+expandingHeight;
					}

					else
					{
						expandingTopLeft.rx() = _terminalPoint.x()-expandingWidth;
						expandingTopLeft.ry() = _terminalPoint.y()-expandingHeight;
						expandingTerminalPoint.rx() = _originPoint.x()+expandingWidth;
						expandingTerminalPoint.ry() = _originPoint.y()+expandingHeight;
					}

					_pExpandingRubberBand->setGeometry(QRect(expandingTopLeft, expandingTerminalPoint).normalized());

					//_pExpandingRubberBand->setGeometry(QRect(_originPoint, _terminalPoint).normalized());
					_pExpandingRubberBand->show();

					_pRubberBand->setGeometry(QRect(_originPoint, _terminalPoint).normalized());
					_pRubberBand->show();

					_pCenterRubberBand->setGeometry(QRect(center-QPoint(3,3), center+QPoint(3,3)).normalized());
					_pCenterRubberBand->show();

				}

				else
				{
					//add
					QPoint expandingTopLeft;
					QPoint expandingTerminalPoint;

					int expandingWidth  = int(_pRubberBand->width()*(_expandingWidthRatio-1)*0.5)+_expandingWidth*_zoomRatio;
					int expandingHeight = int(_pRubberBand->height()*(_expandingHeightRatio-1)*0.5)+_expandingHeight*_zoomRatio;

	/*				expandingTopLeft.rx() = _originPoint.x()-expandingWidth;
					expandingTopLeft.ry() = _originPoint.y()-expandingHeight;
					expandingTerminalPoint.rx() = _terminalPoint.x()+expandingWidth;
					expandingTerminalPoint.ry() = _terminalPoint.y()+expandingHeight;*/

					if ((_originPoint.x()-_terminalPoint.x())*(_originPoint.y()-_terminalPoint.y())<0)
					{
						int y;
						y = _originPoint.y();
						_originPoint.ry() = _terminalPoint.y();
						_terminalPoint.ry() = y;
//.........这里部分代码省略.........
开发者ID:BenJamesbabala,项目名称:SignProcessing,代码行数:101,代码来源:SelectionView.cpp


示例17: qDebug

Magazine::Magazine(QWindow *parent, Base *base)
{
    if (parent == NULL)
    {
        qDebug() << "Error. parent == NULL.";
        exit(-1);
    }
    _parent = parent;
    if (base == NULL)
    {
        qDebug() << "Error. base == NULL.";
        exit(-1);
    }
    _base = base;
    _credits = QRect(10, 5, _parent->geometry().width()/2-10, 25);
    _gold = QRect(_parent->geometry().width()/2+10, 5, _parent->geometry().width()/2-20, 25);
    _one = QRect(10, 10+30, _parent->geometry().width()/2-10, _parent->geometry().height()/2-10-50);
    _capt_one = QRect(10, 10+30, _parent->geometry().width()/2-10, 30);
    _two = QRect(10, _parent->geometry().height()/2+10-50+30, _parent->geometry().width()/2-10, _parent->geometry().height()/2+10-50-30);
    _capt_two = QRect(10, _parent->geometry().height()/2+10-50+30, _parent->geometry().width()/2-10, 30);
    _three = QRect(_parent->geometry().width()/2+10, 10+30, _parent->geometry().width()/2-20, _parent->geometry().height()/2-10-50);
    _capt_three = QRect(_parent->geometry().width()/2+10, 10+30, _parent->geometry().width()/2-20, 30);
    _four = QRect(_parent->geometry().width()/2+10, _parent->geometry().height()/2+10-50+30, _parent->geometry().width()/2-20, _parent->geometry().height()/2+10-50-30);
    _capt_four = QRect(_parent->geometry().width()/2+10, _parent->geometry().height()/2+10-50+30, _parent->geometry().width()/2-20, 30);
    _prev = QRect(10, _parent->geometry().height()-20-50, _parent->geometry().width()/3-10, 60);
    _next = QRect(_parent->geometry().width()/3+10, _parent->geometry().height()-20-50, _parent->geometry().width()/3-20, 60);
    _back = QRect(_parent->geometry().width()/3*2, _parent->geometry().height()-20-50, _parent->geometry().width()/3-10, 60);
    _state = 0;
    _credits_num = "0";
    _gold_num = "0";
}
开发者ID:kvonosan,项目名称:Vibra,代码行数:31,代码来源:magazine.cpp


示例18: qDebug

void SelectionView::mouseMoveEvent( QMouseEvent *e )
{
    if ( _drawLine && _drawLineHold ) {
        cur = e->posF();
        linePath->lineTo( e->posF() );
        qDebug() << "mid: " << e->posF();
        return;
    }

	QPoint topLeft;
	QPoint pointTemp;

	if ( _snapRatio == -1.0 )
		return;

	if (_pRubberBand)
	{
		if (_isFromCenter)
		{
			//*! free ratio
			if (_snapRatio == 0.0)
			{
				pointTemp = e ->pos();
			}
			
			//*!  a ratio is given
			if (_snapRatio != 0.0 && _snapRatio != -1.0 )
			{
				//!* keep the x coordinate the same as the current point while mouse is moving
				//!* make the perpendicular coordinate adjust to the ratio.
				pointTemp.rx() = e->pos().x();
				pointTemp.ry() = _originPoint.y() + (e->pos().x() - _originPoint.x()) * (_snapRatio);
			}
			
			topLeft = _originPoint + _originPoint - pointTemp;
		}
		//!* from the TopLeft
		else
		{
			//!* free ratio
			if (_snapRatio == 0.0)
			{

				topLeft = _originPoint;
				pointTemp = e->pos();
			}
			
			//!* specified ratio
			if (_snapRatio != 0.0 && _snapRatio != -1.0)
			{
				pointTemp.rx() = e->pos().x();
				pointTemp.ry() = _originPoint.y() + (e->pos().x() - _originPoint.x()) * _snapRatio;
				topLeft = _originPoint;
			}
		}


		//!* from center
		if (_isFromCenter)
		{
			_pCenterRubberBand->show();
			_pCenterRubberBand->setGeometry(QRect(_originPoint-QPoint(3,3), _originPoint+QPoint(3,3)).normalized());
		}
		else
			_pCenterRubberBand->hide();

		_pRubberBand->setGeometry(QRect(topLeft, pointTemp).normalized());

		//add
		QPoint expandingTopLeft;
		QPoint expandingpointTemp;

		int expandingWidth  = int(_pRubberBand->width()*(_expandingWidthRatio-1)*0.5)+_expandingWidth*_zoomRatio;
		int expandingHeight = int(_pRubberBand->height()*(_expandingHeightRatio-1)*0.5)+_expandingHeight*_zoomRatio;

		_terminalPoint = pointTemp;

		//add
		if ((topLeft.x()-pointTemp.x())*(topLeft.y()-pointTemp.y())<0)
		{
			int y;
			y = topLeft.y();
			topLeft.ry() = pointTemp.y();
			pointTemp.ry() = y;
		}

		if (topLeft.x()<pointTemp.x())
		{
			expandingTopLeft.rx() = topLeft.x()-expandingWidth;
			expandingTopLeft.ry() = topLeft.y()-expandingHeight;
			expandingpointTemp.rx() = pointTemp.x()+expandingWidth;
			expandingpointTemp.ry() = pointTemp.y()+expandingHeight;
		}

		else
		{
			expandingTopLeft.rx() = pointTemp.x()-expandingWidth;
			expandingTopLeft.ry() = pointTemp.y()-expandingHeight;
			expandingpointTemp.rx() = topLeft.x()+expandingWidth;
			expandingpointTemp.ry() = topLeft.y()+expandingHeight;
//.........这里部分代码省略.........
开发者ID:BenJamesbabala,项目名称:SignProcessing,代码行数:101,代码来源:SelectionView.cpp


示例19: startDrag

void
QueryLabel::mouseMoveEvent( QMouseEvent* event )
{
    QFrame::mouseMoveEvent( event );
    int x = event->x();

    if ( event->buttons() & Qt::LeftButton &&
  

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ QRegExp函数代码示例发布时间:2022-05-30
下一篇:
C++ QRcode_free函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap