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


C++ QRect::adjust方法代码示例

本文整理汇总了C++中QRect::adjust方法的典型用法代码示例。如果您正苦于以下问题:C++ QRect::adjust方法的具体用法?C++ QRect::adjust怎么用?C++ QRect::adjust使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QRect的用法示例。


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

示例1: QFontMetrics

void
CQPropertyDelegate::
drawFont(QPainter *painter, const QStyleOptionViewItem &option,
         const QFont &f, const QModelIndex &index) const
{
  QItemDelegate::drawBackground(painter, option, index);

  QRect rect = option.rect;

  rect.setWidth(option.rect.height());

  rect.adjust(0, 1, -3, -2);

  QFont f1 = f;
  QFont f2 = painter->font();

  QFontMetrics fm1(f1);
  QFontMetrics fm2(f2);

  int fw = fm1.width("Abc");
  int fh = fm1.height();

  if (fh > rect.height()) {
    f1.setPixelSize(rect.height());

    fm1 = QFontMetrics(f1);

    fw = fm1.width("Abc");
  }

  int x1 = rect.left();
  int y1 = rect.top() + fm1.ascent();

  painter->save();

  painter->setFont(f1);
  painter->setPen(QColor(0,0,0));

  painter->drawText(x1, y1, "Abc");

  painter->restore();

  int x2 = x1 + fw + 4;
//int y2 = rect.top() + fm2.ascent();

  QRect rect1;

  rect1.setCoords(x2, option.rect.top(), option.rect.right(), option.rect.bottom());

//painter->drawText(x2, y2, f.toString());
  QItemDelegate::drawDisplay(painter, option, rect1, f.toString());
}
开发者ID:colinw7,项目名称:CQPropertyTree,代码行数:52,代码来源:CQPropertyDelegate.cpp

示例2: updateCountImage

/**
 * Update the number of unread messages in the tray icon
 */
void KCheckGmailTray::updateCountImage(QColor color)
{
    kDebug() << k_funcinfo << "Count=" << mMailCount;

    if(mMailCount == 0)
        setPixmapEmpty();
    else {
        // adapted from KMSystemTray::updateCount()

        int oldPixmapWidth = mPixGmail.size().width();

        QString countString = QString::number( mMailCount );
        QFont countFont = KGlobalSettings::generalFont();
        countFont.setBold(true);

        // decrease the size of the font for the number of unread messages if the
        // number doesn't fit into the available space
        float countFontSize = countFont.pointSizeF();
        QFontMetrics qfm( countFont );
        int width = qfm.width( countString );
        if( width > (oldPixmapWidth - 2) )
        {
            countFontSize *= float( oldPixmapWidth - 2 ) / float( width );
            countFont.setPointSizeF( countFontSize );
        }

        // Overlay the light KCheckGmail image with the number image
        QImage iconWithNumberImage = mLightIconImage.copy();
        QPainter p( &iconWithNumberImage );
        p.setFont( countFont );
        KColorScheme scheme( QPalette::Active, KColorScheme::View );

        qfm = QFontMetrics( countFont );
        QRect boundingRect = qfm.tightBoundingRect( countString );
        boundingRect.adjust( 0, 0, 0, 2 );
        boundingRect.setHeight( qMin( boundingRect.height(), oldPixmapWidth ) );
        boundingRect.moveTo( (oldPixmapWidth - boundingRect.width()) / 2,
                             ((oldPixmapWidth - boundingRect.height()) / 2) - 1 );
        p.setOpacity( 0.7 );
        p.setBrush( scheme.background( KColorScheme::LinkBackground ) );
        p.setPen( scheme.background( KColorScheme::LinkBackground ).color() );
        p.drawRoundedRect( boundingRect, 2.0, 2.0 );

        p.setBrush( Qt::NoBrush );
//		p.setPen( scheme.foreground( KColorScheme::LinkText ).color() );
        p.setPen(color);
        p.setOpacity( 1.0 );
        p.drawText( iconWithNumberImage.rect(), Qt::AlignCenter, countString );

        setIcon( QPixmap::fromImage( iconWithNumberImage ) );
    }
}
开发者ID:netrunner-debian-kde-extras,项目名称:kcheckgmail,代码行数:55,代码来源:kcheckgmailtray.cpp

示例3: main

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

#ifdef WIN32
    // Make sure there is a console to get our stdout,stderr information
    AllocConsole();
    HANDLE stdOutHandle=GetStdHandle(STD_OUTPUT_HANDLE);
    int hConHandle=_open_osfhandle((intptr_t)stdOutHandle,_O_TEXT);
    FILE* fp=_fdopen((int)hConHandle,"w");
    *stdout=*fp;
    setvbuf(stdout,NULL,_IONBF,0);
    HANDLE stdErrHandle=GetStdHandle(STD_ERROR_HANDLE);
    int hConHandleErr=_open_osfhandle((intptr_t) stdOutHandle,_O_TEXT);
    FILE* fperr=_fdopen( (int)hConHandleErr,"w");
    *stderr=*fperr;
    setvbuf(stderr,NULL,_IONBF,0);
    std::ios::sync_with_stdio();
    std::cerr<<"BRDF Version "<<BRDF_VERSION<<std::endl;
//    std::cerr<<"stdout: BRDF Version "<<BRDF_VERSION<<std::endl;
#endif

    // make sure we can open the data files
    if( !checkTeapot() ) {
        QString errString = "Can't open data files.\n\nPlease run BRDF Explorer from the directory containing the data/, images/, probes/, and shaderTemplates/ subdirectories (probably the src/ directory).";
        QMessageBox::critical( NULL, "BRDF Explorer", errString );
        return 1;
    }

    
    // center the window in the middle of the default screen
    QDesktopWidget desktopWidget;
    QRect rect = desktopWidget.screenGeometry();
    rect.adjust( 60, 60, -60, -60 );

    MainWindow main;
    main.setGeometry(rect);
    main.show();
    
    
    
    // open all BRDFs passed in on the commandline
    if( argc > 1 )
    {
        std::vector<std::string> files;
        for( int i = 1; i < argc; i++ )           
            files.push_back( std::string(argv[i]) );
        main.getParameterWindow()->openBRDFFiles( files );
    }
    
    return app.exec();
}
开发者ID:ArieLeo,项目名称:brdf,代码行数:52,代码来源:main.cpp

示例4: paint

// virtual
void AbstractGroupItem::paint(QPainter *p, const QStyleOptionGraphicsItem *option, QWidget *)
{
    const double scale = option->matrix.m11();
    QRect clipRect = option->exposedRect.toRect();
    clipRect.adjust(0, 0, 1 / scale + 0.5, 1);
    p->fillRect(option->exposedRect, QColor(100, 100, 200, 100));
    p->setClipRect(clipRect);
    QPen pen = p->pen();
    pen.setColor(QColor(200, 90, 90));
    pen.setStyle(Qt::DashLine);
    p->setPen(pen);
    p->drawRect(boundingRect());
}
开发者ID:rayl,项目名称:kdenlive,代码行数:14,代码来源:abstractgroupitem.cpp

示例5: updateGeometry

    //____________________________________________________________________________________
    void SunkenFrameShadow::updateGeometry()
    {

        QWidget *widget = parentWidget();
        if( !widget ) return;

        QRect cr = widget->contentsRect();
        switch (shadowArea())
        {

            case Top:
            cr.setHeight( SHADOW_SIZE_TOP );
            cr.adjust( -1, -1, 1, 0 );
            break;

            case Left:
            cr.setWidth(SHADOW_SIZE_LEFT);
            cr.adjust(-1, SHADOW_SIZE_TOP, 0, -SHADOW_SIZE_BOTTOM);
            break;


            case Bottom:
            cr.setTop(cr.bottom() - SHADOW_SIZE_BOTTOM + 1);
            cr.adjust( -1, 0, 1, 1 );
            if( hasContrast() ) cr.adjust( 0, 0, 0, 1 );
            break;

            case Right:
            cr.setLeft(cr.right() - SHADOW_SIZE_RIGHT + 1);
            cr.adjust(0, SHADOW_SIZE_TOP, 1, -SHADOW_SIZE_BOTTOM);
            break;

            case Unknown:
            default:
            return;
        }

        setGeometry(cr);
    }
开发者ID:KDE,项目名称:oxygen-transparent,代码行数:40,代码来源:oxygenframeshadow.cpp

示例6: leftArcRect

void
drawBackgroundAndNumbers( QPainter* painter, const QString& text, const QRect& figRectIn )
{
    painter->save();

    QRect figRect = figRectIn;
    if ( text.length() == 1 )
        figRect.adjust( -painter->fontMetrics().averageCharWidth(), 0, 0, 0 );

    QPen origpen = painter->pen();
    QPen pen = origpen;
    pen.setWidth( 1.0 );
    painter->setPen( pen );
    painter->drawRect( figRect );

    // circles look bad. make it an oval. (thanks, apple)
    const int bulgeWidth = 8;
    const int offset = 0; // number of pixels to begin, counting inwards from figRect.x() and figRect.width(). 0 means start at each end, negative means start inside the rect.

    QPainterPath ppath;
    ppath.moveTo( QPoint( figRect.x() + offset, figRect.y() + figRect.height() / 2 ) );
    QRect leftArcRect( figRect.x() + offset - bulgeWidth, figRect.y(), 2*bulgeWidth, figRect.height() );
    ppath.arcTo( leftArcRect, 90, 180 );
    painter->drawPath( ppath );

    ppath = QPainterPath();
    ppath.moveTo( figRect.x() + figRect.width() - offset, figRect.y() + figRect.height() / 2 );
    leftArcRect = QRect( figRect.x() + figRect.width() - offset - bulgeWidth, figRect.y(), 2*bulgeWidth, figRect.height() );
    ppath.arcTo( leftArcRect, 270, 180 );
    painter->drawPath( ppath );

    figRect.adjust( -1, 0, 0, 0 );

    painter->setPen( origpen );
    painter->setPen( Qt::white );
    painter->drawText( figRect.adjusted( -5, 0, 6, 0 ), text, QTextOption( Qt::AlignCenter ) );

    painter->restore();
}
开发者ID:demelziraptor,项目名称:tomahawk,代码行数:39,代码来源:TomahawkUtilsGui.cpp

示例7: paintEvent

void ParticlesExtraInfoColumn::paintEvent(QPaintEvent *)
{
	if (!this->timeLineWidget)
	{
		return;
	}
	
	QPainter painter(this);
	painter.setPen(Qt::black);
	
	QRect ourRect = rect();
	ourRect.adjust(0, 0, -1, -1);
	painter.drawRect(ourRect);
	
	// Draw the header.
	painter.setFont(timeLineWidget->nameFont);
	painter.setPen(Qt::black);
	QRect textRect(0, 0, rect().width(), TOP_INDENT);
	painter.drawRect(textRect);
	painter.drawText(textRect, Qt::AlignHCenter | Qt::AlignVCenter, GetExtraInfoHeader());
	
	// Draw the per-layer particles count.
	OnBeforeGetExtraInfoLoop();
	
	QFontMetrics fontMetrics(timeLineWidget->nameFont);
	painter.setFont(timeLineWidget->nameFont);
	
	int32 i = 0;
	for (ParticleTimeLineWidget::LINE_MAP::const_iterator iter = timeLineWidget->lines.begin();
		 iter != timeLineWidget->lines.end(); ++iter, ++i)
	{
		const ParticleTimeLineWidget::LINE& line = iter->second;
		
		painter.setPen(QPen(line.color, LINE_WIDTH));
		int startY = i * LINE_STEP + LINE_STEP / 2;
		QRect textRect (EXTRA_INFO_LEFT_PADDING, TOP_INDENT + startY,
						rect().width() - EXTRA_INFO_LEFT_PADDING, LINE_STEP);
		painter.drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter,
						 GetExtraInfoForLayerLine(line));
	}
	
	OnAfterGetExtraInfoLoop();
	
	// Draw the "Total" box.
	QPoint totalPoint(EXTRA_INFO_LEFT_PADDING, rect().bottom() - 3);
	QFont totalFont = timeLineWidget->nameFont;
	totalFont.setBold(true);
	
	painter.setPen(QPen(Qt::black, LINE_WIDTH));
	painter.drawText(totalPoint, GetExtraInfoFooter());
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:51,代码来源:ParticleTimeLineColumns.cpp

示例8: paintSection

void QxtScheduleHeaderWidget::paintSection(QPainter * painter, const QRect & rect, int logicalIndex) const
{
    if (model())
    {
        switch (orientation())
        {
        case Qt::Horizontal:
        {
            QHeaderView::paintSection(painter, rect, logicalIndex);
        }
        break;
        case Qt::Vertical:
        {
            QTime time = model()->headerData(logicalIndex, Qt::Vertical, Qt::DisplayRole).toTime();
            if (time.isValid())
            {
                QRect temp = rect;
                temp.adjust(1, 1, -1, -1);

                painter->fillRect(rect, this->palette().background());

                switch (time.minute())
                {
                    case 00:
                        painter->drawLine(temp.topLeft() + QPoint(temp.width() / 3, 0), temp.topRight());
                        painter->drawText(temp, Qt::AlignTop | Qt::AlignRight, time.toString("hh:mm"));
                        break;

                    case 30:
                        painter->drawLine(temp.topLeft() + QPoint(temp.width() / 2, 0), temp.topRight());
                        break;

                    case 45:
                    case 15:
                        painter->drawLine(temp.topLeft() + QPoint(temp.width() / 1.5, 0), temp.topRight());
                        break;
                }

//                if (time.minute() == 0)
//                {
//                    painter->drawLine(temp.topLeft() + QPoint(temp.width() / 3, 0), temp.topRight());
//                    painter->drawText(temp, Qt::AlignTop | Qt::AlignRight, time.toString("hh:mm"));
//                }
            }
        }
        break;
        default:
            Q_ASSERT(false); //this will never happen... normally
        }
    }
}
开发者ID:DentalTask,项目名称:main,代码行数:51,代码来源:qxtscheduleheaderwidget.cpp

示例9: paintEvent

void TPanel::paintEvent(QPaintEvent *e) {
  QPainter painter(this);

  if (widget()) {
    QRect dockRect = widget()->geometry();

    dockRect.adjust(0, 0, -1, -1);
    painter.fillRect(dockRect, m_bgcolor);
    painter.setPen(Qt::black);
    painter.drawRect(dockRect);
  }

  painter.end();
}
开发者ID:Makoto-Sasahara,项目名称:opentoonz,代码行数:14,代码来源:pane.cpp

示例10: searchRect

// --------------------------------------------------
QRect ctkSearchBoxPrivate::searchRect()const
{
  Q_Q(const ctkSearchBox);
  QRect sRect = q->contentsRect();
  // If the QLineEdit has a frame, the icon must be shifted from
  // the frame line width
  if (q->hasFrame())
    {
#if QT_VERSION < QT_VERSION_CHECK(5,0,0)
    QStyleOptionFrameV2 opt;
#else
    QStyleOptionFrame opt;
#endif
    q->initStyleOption(&opt);
    sRect.adjust(opt.lineWidth, opt.lineWidth, -opt.lineWidth, -opt.lineWidth);
    }
  // Hardcoded: shrink by 1 pixel because some styles have a focus frame inside
  // the line edit frame.
  sRect.adjust(1, 1, -1, -1);
  // Square size
  sRect.setWidth(sRect.height());
  return sRect;
}
开发者ID:iRomii,项目名称:CTK,代码行数:24,代码来源:ctkSearchBox.cpp

示例11: updateUnreadCount

void SysTrayIcon::updateUnreadCount( int changeOfUnreadPosts )
{
    kDebug();
    unread += changeOfUnreadPosts;

    if ( unread <= 0 ) {
        setIconByName(currentIconName());
        unread = 0;
    } else {
        // adapted from KMSystemTray::updateCount()
        int oldWidth = 22;

        QString countStr = QString::number( unread );
        QFont f = KGlobalSettings::generalFont();
        f.setBold( true );

        float pointSize = f.pointSizeF();
        QFontMetrics fm( f );
        int w = fm.width( countStr );
        if ( w > ( oldWidth - 2 ) ) {
            pointSize *= float( oldWidth - 2 ) / float( w );
            f.setPointSizeF( pointSize );
        }

        // overlay
        QPixmap overlayImg = KIcon(currentIconName()).pixmap(22,22);
        QPainter p( &overlayImg );
        p.setFont( f );
        KColorScheme scheme( QPalette::Active, KColorScheme::View );

        fm = QFontMetrics( f );
        QRect boundingRect = fm.tightBoundingRect( countStr );
        boundingRect.adjust( 0, 0, 0, 2 );
        boundingRect.setHeight( qMin( boundingRect.height(), oldWidth ) );
        boundingRect.moveTo(( oldWidth - boundingRect.width() ) / 2,
                            (( oldWidth - boundingRect.height() ) / 2 ) - 1 );
        p.setOpacity( 0.7 );
        QBrush br(QColor(255, 255, 255), Qt::SolidPattern);
        p.setBrush( br );
        p.setPen( QColor(255, 255, 255) );
        p.drawRoundedRect( boundingRect, 2.0, 2.0 );

        p.setBrush( Qt::NoBrush );
        p.setPen( QColor( 0, 0, 0 ) );
        p.setOpacity( 1.0 );
        p.drawText( overlayImg.rect(), Qt::AlignCenter, countStr );
        setIconByPixmap( overlayImg );
    }
    this->setToolTip( "choqok", i18n("Choqok"), i18np( "1 unread post", "%1 unread posts", unread ) );
}
开发者ID:Boris-de,项目名称:choqok,代码行数:50,代码来源:systrayicon.cpp

示例12: loadItemPositions

void DesktopWindow::loadItemPositions() {
    // load custom item positions
    customItemPos_.clear();
    Settings& settings = static_cast<Application*>(qApp)->settings();
    QString configFile = QString("%1/desktop-items-%2.conf").arg(settings.profileDir(settings.profileName())).arg(screenNum_);
    QSettings file(configFile, QSettings::IniFormat);

    auto delegate = static_cast<Fm::FolderItemDelegate*>(listView_->itemDelegateForColumn(0));
    auto grid = delegate->itemSize();
    QRect workArea = qApp->desktop()->availableGeometry(screenNum_);
    workArea.adjust(12, 12, -12, -12);
    char* dektopPath = Fm::Path::getDesktop().toStr();
    QString desktopDir = QString(dektopPath) + QString("/");
    g_free(dektopPath);

    std::vector<QPoint> usedPos;
    for(auto& item: customItemPos_) {
        usedPos.push_back(item.second);
    }

    // FIXME: this is inefficient
    Q_FOREACH(const QString& name, file.childGroups()) {
        if(!QFile::exists(desktopDir + name.toUtf8())) {
            // the file may have been removed from outside LXQT
            continue;
        }
        file.beginGroup(name);
        QVariant var = file.value("pos");
        if(var.isValid()) {
            QPoint customPos = var.toPoint();
            if(customPos.x() >= workArea.x() && customPos.y() >= workArea.y()
                    && customPos.x() + grid.width() <= workArea.right() + 1
                    && customPos.y() + grid.height() <= workArea.bottom() + 1) {
                // correct positions that are't aligned to the grid
                alignToGrid(customPos, workArea.topLeft(), grid, listView_->spacing());
                // FIXME: this is very inefficient
                while(std::find(usedPos.cbegin(), usedPos.cend(), customPos) != usedPos.cend()) {
                    customPos.setY(customPos.y() + grid.height() + listView_->spacing());
                    if(customPos.y() + grid.height() > workArea.bottom() + 1) {
                        customPos.setX(customPos.x() + grid.width() + listView_->spacing());
                        customPos.setY(workArea.top());
                    }
                }
                customItemPos_[name.toStdString()] = customPos;
                usedPos.push_back(customPos);
            }
        }
        file.endGroup();
    }
}
开发者ID:SafaAlfulaij,项目名称:pcmanfm-qt,代码行数:50,代码来源:desktopwindow.cpp

示例13: moveEvent

void KateTabButton::moveEvent(QMoveEvent *event)
{
    // tell the tabbar to redraw its separators. Since the separators overlap
    // the tab buttons geometry, we need to adjust the width by the separator's
    // width to avoid artifacts
    if (parentWidget()) {
        const int w = style()->pixelMetric(QStyle::PM_ToolBarSeparatorExtent, 0, this);
        QRect rect = geometry();
        rect.moveLeft(event->oldPos().x());
        rect.adjust(-w, 0, w, 0);
        parentWidget()->update(rect);
    }
    QAbstractButton::moveEvent(event);
}
开发者ID:cmacq2,项目名称:kate,代码行数:14,代码来源:katetabbutton.cpp

示例14: drawSpan

void QxtSpanSliderPrivate::drawSpan(QStylePainter* painter, const QRect& rect) const
{
    QStyleOptionSlider opt;
    initStyleOption(&opt);
    const QSlider* p = &qxt_p();

    // area
    QRect groove = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderGroove, p);
    if (opt.orientation == Qt::Horizontal)
        groove.adjust(0, 0, -1, 0);
    else
        groove.adjust(0, 0, 0, -1);

    // pen & brush
    painter->setPen(QPen(p->palette().color(QPalette::Dark).light(110), 0));
    if (opt.orientation == Qt::Horizontal)
        setupPainter(painter, opt.orientation, groove.center().x(), groove.top(), groove.center().x(), groove.bottom());
    else
        setupPainter(painter, opt.orientation, groove.left(), groove.center().y(), groove.right(), groove.center().y());

    // draw groove
    painter->drawRect(rect.intersected(groove));
}
开发者ID:dshean,项目名称:trunk,代码行数:23,代码来源:qxtspanslider.cpp

示例15: updateEditorGeometry

void QtPropertyItemDelegate::updateEditorGeometry(QWidget * editor, const QStyleOptionViewItem & option, const QModelIndex & index) const
{
	QStyledItemDelegate::updateEditorGeometry(editor, option, index);

	// tune widget border and geometry
	if(NULL != editor)
	{
		editor->setObjectName("customPropertyEditor");
		editor->setStyleSheet("#customPropertyEditor{ border: 1px solid gray; }");
		QRect r = option.rect;
		r.adjust(2, -1, 0, 1);
		editor->setGeometry(r);
	}
}
开发者ID:,项目名称:,代码行数:14,代码来源:


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