这篇教程C++ viewport函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中viewport函数的典型用法代码示例。如果您正苦于以下问题:C++ viewport函数的具体用法?C++ viewport怎么用?C++ viewport使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了viewport函数的21个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: viewportvoid View::resizeEvent( QResizeEvent * event ){ if ( QGraphicsScene * scene_ = scene() ) scene_->setSceneRect( 0, 0, viewport()->width(), viewport()->height() ); QGraphicsView::resizeEvent(event);}
开发者ID:0xd0d9e,项目名称:anthracitarium,代码行数:6,
示例2: viewportvoid HistogramView::dataChanged(const QModelIndex &topLeft,const QModelIndex &bottomRight){ QAbstractItemView::dataChanged(topLeft,bottomRight); viewport()->update();}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:5,
示例3: painter// paintEvent()函数具体完成柱状统计图绘制的工作void HistogramView::paintEvent(QPaintEvent *){ QPainter painter(viewport()); painter.setPen(Qt::black); int x0=40; int y0=250; //y坐标轴 painter.drawLine(x0,y0,40,30); painter.drawLine(38,32,40,30); painter.drawLine(40,30,42,32); painter.drawText(20,30,tr("人数")); for(int i=1;i<5;i++) { painter.drawLine(-1,-i*50,1,-i*50); painter.drawText(-20,-i*50,tr("%1").arg(i*5)); } //x 坐标轴 painter.drawLine(x0,y0,540,250); painter.drawLine(538,248,540,250); painter.drawLine(540,250,538,252); painter.drawText(545,250,tr("部门")); int posD=x0+20; int row; for(row=0;row<model()->rowCount(rootIndex());row++) { QModelIndex index=model()->index(row,0,rootIndex()); QString dep=model()->data(index).toString(); painter.drawText(posD,y0+20,dep); posD+=50; } //男 int posM=x0+20; for(row=0;row<model()->rowCount(rootIndex());row++) { QModelIndex index=model()->index(row,1,rootIndex()); int male=model()->data(index).toDouble(); int width=10; if(selections->isSelected(index)) painter.setBrush(QBrush(Qt::blue,Qt::Dense3Pattern)); else painter.setBrush(Qt::blue); painter.drawRect(QRect(posM,y0-male*10,width,male*10)); QRegion regionM(posM,y0-male*10,width,male*10); MRegionList<<regionM; posM+=50; } //女 int posF=x0+30; for(row=0;row<model()->rowCount(rootIndex());row++) { QModelIndex index=model()->index(row,2,rootIndex()); int female=model()->data(index).toDouble(); int width=10; if(selections->isSelected(index)) painter.setBrush(QBrush(Qt::red,Qt::Dense3Pattern)); else painter.setBrush(Qt::red); painter.drawRect(QRect(posF,y0-female*10,width,female*10)); QRegion regionF(posF,y0-female*10,width,female*10); FRegionList<<regionF; posF+=50; } //退休 int posS=x0+40; for(row=0;row<model()->rowCount(rootIndex());row++) { QModelIndex index=model()->index(row,3,rootIndex()); int retire=model()->data(index).toDouble(); int width=10; if(selections->isSelected(index)) painter.setBrush(QBrush(Qt::green,Qt::Dense3Pattern)); else painter.setBrush(Qt::green); painter.drawRect(QRect(posS,y0-retire*10,width,retire*10)); QRegion regionS(posS,y0-retire*10,width,retire*10); SRegionList<<regionS; posS+=50; }}
开发者ID:Pengfei-Gao,项目名称:develop-reference-data,代码行数:91,
示例4: contentsMovedvoid GraphicsDImgView::finishPanning(){ emit contentsMoved(true); viewport()->unsetCursor();}
开发者ID:KDE,项目名称:digikam,代码行数:5,
示例5: Q_Dbool KFollowWindow::eventFilter( QObject *obj, QEvent *e ){ Q_D(KFollowWindow); if(d->target == NULL) return false; if(obj == d->target->viewport()) { switch(e->type()) { case QEvent::WindowActivate: { int i = 0; } break; case QEvent::WindowDeactivate: { if(!isVisible()) { return false; } if(d->hideFlags & TargetWindowInactive) { bool bAborted = false; emit aboutToHide(TargetWindowInactive, &bAborted); if(!bAborted) { QMetaObject::invokeMethod(this, "hide", Qt::QueuedConnection); } } } break; case QEvent::MouseButtonPress: { if(!isVisible()) { return false; } if(d->target->isUnderMouse()) { if(d->hideFlags & ClickAtTarget) { bool bAborted = false; emit aboutToHide(ClickAtTarget, &bAborted); if(!bAborted) { QMetaObject::invokeMethod(this, "hide", Qt::QueuedConnection); } } } else { if(d->hideFlags & ClickAtOther) { bool bAborted = false; emit aboutToHide(ClickAtOther, &bAborted); if(!bAborted) { QMetaObject::invokeMethod(this, "hide", Qt::QueuedConnection); } } } } break; case QEvent::Move: { if(!isVisible()) { return false; } if(d->hideFlags & TargetWindowMoving) { bool bAborted = false; emit aboutToHide(TargetWindowMoving, &bAborted); if(!bAborted) { QMetaObject::invokeMethod(this, "hide", Qt::QueuedConnection); } } } break; case QEvent::Resize: { if(!isVisible()) { return false; } if(d->hideFlags & TargetWindowResize) { bool bAborted = false; emit aboutToHide(TargetWindowResize, &bAborted); if(!bAborted) { QMetaObject::invokeMethod(this, "hide", Qt::QueuedConnection); } } } break; case QEvent::ParentChange: {//.........这里部分代码省略.........
开发者ID:kxtry,项目名称:kxfw,代码行数:101,
示例6: viewport// setup matrices and viewport (upto you to push and pop view before and after)// if width or height are 0, assume windows dimensions (ofGetWidth(), ofGetHeight())// if nearDist or farDist are 0 assume defaults (calculated based on width / height)void ofCairoRenderer::viewport(ofRectangle v){ viewport(v.x,v.y,v.width,v.height);}
开发者ID:alfredoBorboa,项目名称:openFrameworks,代码行数:6,
示例7: QBrushvoid QHexEdit::setHighlightingColor(const QColor &color){ _brushHighlighted = QBrush(color); _penHighlighted = QPen(viewport()->palette().color(QPalette::WindowText)); viewport()->update();}
开发者ID:hellprototypes,项目名称:Hell-serial-tool,代码行数:6,
示例8: viewportvoid QHexEdit::setAsciiArea(bool asciiArea){ _asciiArea = asciiArea; viewport()->update();}
开发者ID:hellprototypes,项目名称:Hell-serial-tool,代码行数:5,
示例9: paintervoid ByteViewText::paintEvent(QPaintEvent *){ QPainter painter(viewport()); painter.translate(-horizontalScrollBar()->value() * font_width_, 0); // Pixel offset of this row int row_y = 0; // Starting byte offset int offset = verticalScrollBar()->value() * row_width_; // Clear the area painter.fillRect(viewport()->rect(), palette().base()); // Offset background. We want the entire height to be filled. if (show_offset_) { QRect offset_rect = QRect(viewport()->rect()); offset_rect.setWidth(offsetPixels()); painter.fillRect(offset_rect, palette().window()); } if ( data_.isEmpty() ) { return; } // Data rows int widget_height = height(); int leading = fontMetrics().leading(); painter.save(); x_pos_to_column_.clear(); while( (int) (row_y + line_height_) < widget_height && offset < (int) data_.count()) { drawLine(&painter, offset, row_y); offset += row_width_; row_y += line_height_ + leading; } painter.restore(); // We can't do this in drawLine since the next line might draw over our rect. if (!hover_outlines_.isEmpty()) { qreal pen_width = 1.0; qreal hover_alpha = 0.6; QPen ho_pen; QColor ho_color = palette().text().color(); if (marked_byte_offset_ < 0) { hover_alpha = 0.3; if (devicePixelRatio() > 1) { pen_width = 0.5; } } ho_pen.setWidthF(pen_width); ho_color.setAlphaF(hover_alpha); ho_pen.setColor(ho_color); painter.save(); painter.setPen(ho_pen); painter.setBrush(Qt::NoBrush); foreach (QRect ho_rect, hover_outlines_) { // These look good on retina and non-retina displays on macOS. // We might want to use fontMetrics numbers instead. ho_rect.adjust(-1, 0, -1, -1); painter.drawRect(ho_rect); }
开发者ID:alagoutte,项目名称:wireshark,代码行数:64,
示例10: viewportvoid ByteViewText::markAppendix(int start, int length){ field_a_start_ = start; field_a_len_ = length; viewport()->update();}
开发者ID:alagoutte,项目名称:wireshark,代码行数:6,
示例11: qMaxvoid ByteViewText::setFieldAppendixHighlight(int start, int end){ fa_bound_ = QPair<guint, guint>(qMax(0, start), qMax(0, end)); fa_bound_save_ = f_bound_; viewport()->update();}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:6,
示例12: setCursorPosition// ********************************************************************** Handle eventsvoid QHexEdit::keyPressEvent(QKeyEvent *event){ // Cursor movements if (event->matches(QKeySequence::MoveToNextChar)) { setCursorPosition(_cursorPosition + 1); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousChar)) { setCursorPosition(_cursorPosition - 1); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToEndOfLine)) { setCursorPosition(_cursorPosition | (2 * BYTES_PER_LINE -1)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToStartOfLine)) { setCursorPosition(_cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE))); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousLine)) { setCursorPosition(_cursorPosition - (2 * BYTES_PER_LINE)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToNextLine)) { setCursorPosition(_cursorPosition + (2 * BYTES_PER_LINE)); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToNextPage)) { setCursorPosition(_cursorPosition + (((_rowsShown - 1) * 2 * BYTES_PER_LINE))); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToPreviousPage)) { setCursorPosition(_cursorPosition - (((_rowsShown - 1) * 2 * BYTES_PER_LINE))); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToEndOfDocument)) { setCursorPosition(_chunks->size() * 2); resetSelection(_cursorPosition); } if (event->matches(QKeySequence::MoveToStartOfDocument)) { setCursorPosition(0); resetSelection(_cursorPosition); } // Select commands if (event->matches(QKeySequence::SelectAll)) { resetSelection(0); setSelection(2*_chunks->size() + 1); } if (event->matches(QKeySequence::SelectNextChar)) { qint64 pos = _cursorPosition + 1; setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousChar)) { qint64 pos = _cursorPosition - 1; setSelection(pos); setCursorPosition(pos); } if (event->matches(QKeySequence::SelectEndOfLine)) { qint64 pos = _cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE)) + (2 * BYTES_PER_LINE); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectStartOfLine)) { qint64 pos = _cursorPosition - (_cursorPosition % (2 * BYTES_PER_LINE)); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectPreviousLine)) { qint64 pos = _cursorPosition - (2 * BYTES_PER_LINE); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextLine)) { qint64 pos = _cursorPosition + (2 * BYTES_PER_LINE); setCursorPosition(pos); setSelection(pos); } if (event->matches(QKeySequence::SelectNextPage)) { qint64 pos = _cursorPosition + (((viewport()->height() / _pxCharHeight) - 1) * 2 * BYTES_PER_LINE);//.........这里部分代码省略.........
开发者ID:hellprototypes,项目名称:Hell-serial-tool,代码行数:101,
示例13: viewportvoid ByteViewText::setEncoding(packet_char_enc encoding){ encoding_ = encoding; viewport()->update();}
开发者ID:Nicholas1126,项目名称:wireshark-ex,代码行数:5,
示例14: paintervoid QHexEdit::paintEvent(QPaintEvent *event){ QPainter painter(viewport()); if (event->rect() != _cursorRect) { // process some useful calculations int pxOfsX = horizontalScrollBar()->value(); int pxPosStartY = _pxCharHeight; // draw some patterns if needed painter.fillRect(event->rect(), viewport()->palette().color(QPalette::Base)); if (_addressArea) painter.fillRect(QRect(-pxOfsX, event->rect().top(), _pxPosHexX - _pxGapAdrHex/2 - pxOfsX, height()), _addressAreaColor); if (_asciiArea) { int linePos = _pxPosAsciiX - (_pxGapHexAscii / 2); painter.setPen(Qt::gray); painter.drawLine(linePos - pxOfsX, event->rect().top(), linePos - pxOfsX, height()); } painter.setPen(viewport()->palette().color(QPalette::WindowText)); // paint address area if (_addressArea) { QString address; for (int row=0, pxPosY = _pxCharHeight; row <= (_dataShown.size()/BYTES_PER_LINE); row++, pxPosY +=_pxCharHeight) { address = QString("%1").arg(_bPosFirst + row*BYTES_PER_LINE + _addressOffset, _addrDigits, 16, QChar('0')); painter.drawText(_pxPosAdrX - pxOfsX, pxPosY, address); } } // paint hex and ascii area QPen colStandard = QPen(viewport()->palette().color(QPalette::WindowText)); painter.setBackgroundMode(Qt::TransparentMode); for (int row = 0, pxPosY = pxPosStartY; row <= _rowsShown; row++, pxPosY +=_pxCharHeight) { QByteArray hex; int pxPosX = _pxPosHexX - pxOfsX; int pxPosAsciiX2 = _pxPosAsciiX - pxOfsX; qint64 bPosLine = row * BYTES_PER_LINE; for (int colIdx = 0; ((bPosLine + colIdx) < _dataShown.size() && (colIdx < BYTES_PER_LINE)); colIdx++) { QColor c = viewport()->palette().color(QPalette::Base); painter.setPen(colStandard); qint64 posBa = _bPosFirst + bPosLine + colIdx; if ((getSelectionBegin() <= posBa) && (getSelectionEnd() > posBa)) { c = _brushSelection.color(); painter.setPen(_penSelection); } else { if (_highlighting) if (_markedShown.at((int)(posBa - _bPosFirst))) { c = _brushHighlighted.color(); painter.setPen(_penHighlighted); } } // render hex value QRect r; if (colIdx == 0) r.setRect(pxPosX, pxPosY - _pxCharHeight + _pxSelectionSub, 2*_pxCharWidth, _pxCharHeight); else r.setRect(pxPosX - _pxCharWidth, pxPosY - _pxCharHeight + _pxSelectionSub, 3*_pxCharWidth, _pxCharHeight); painter.fillRect(r, c); hex = _hexDataShown.mid((bPosLine + colIdx) * 2, 2); painter.setPen(QColor::fromRgb(0, 128, 0)); painter.drawText(pxPosX, pxPosY, hex); pxPosX += 3*_pxCharWidth; // render ascii value if (_asciiArea) { char ch = _dataShown.at(bPosLine + colIdx); if ((ch < 0x20) || (ch > 0x7e)) ch = '.'; r.setRect(pxPosAsciiX2, pxPosY - _pxCharHeight + _pxSelectionSub, _pxCharWidth, _pxCharHeight); painter.fillRect(r, c); painter.drawText(pxPosAsciiX2, pxPosY, QChar(ch)); pxPosAsciiX2 += _pxCharWidth; } } } painter.setBackgroundMode(Qt::TransparentMode); painter.setPen(viewport()->palette().color(QPalette::WindowText)); } // paint cursor if (_blink && !_readOnly && hasFocus()) painter.fillRect(_cursorRect, this->palette().color(QPalette::WindowText)); else painter.drawText(_pxCursorX, _pxCursorY, _hexDataShown.mid(_cursorPosition - _bPosFirst * 2, 1));//.........这里部分代码省略.........
开发者ID:hellprototypes,项目名称:Hell-serial-tool,代码行数:101,
示例15: viewportRectChangedvoid GraphicsDImgView::scrollContentsBy(int dx, int dy){ QGraphicsView::scrollContentsBy(dx, dy); emit viewportRectChanged(mapToScene(viewport()->rect()).boundingRect());}
开发者ID:KDE,项目名称:digikam,代码行数:5,
示例16: mapToSceneQRectF CanvasContainer::visualRect() const{ return proxy->mapFromScene( mapToScene(viewport()->rect())) .boundingRect().intersected(proxy->rect());}
开发者ID:leosama,项目名称:painttyWidget,代码行数:6,
示例17: returnQRect GraphicsDImgView::visibleArea() const{ return (mapToScene(viewport()->geometry()).boundingRect().toRect());}
开发者ID:KDE,项目名称:digikam,代码行数:4,
示例18: QWidgetQWidget* CanvasContainer::scaleSlider(){ if (!scaleSliderWidget) { scaleSliderWidget = new QWidget(this); QHBoxLayout *layout = new QHBoxLayout(scaleSliderWidget); QSlider *slider = new QSlider(Qt::Horizontal, scaleSliderWidget); QLabel *label = new QLabel("100%", scaleSliderWidget); label->setFixedWidth(label->fontMetrics().width("100.%")); label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); //label->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); //not working? scaleSliderWidget->setLayout(layout); layout->addWidget(slider); layout->addWidget(label); layout->setContentsMargins(0, 0, 0, 0); qreal internalFactor = -100 * qLn(MIN_SCALE_FACTOR) / MIN_SCALE_FACTOR / qLn(2); slider->setRange(-qCeil(MIN_SCALE_FACTOR * internalFactor), qCeil(MAX_SCALE_FACTOR - 1) * 100); slider->setPageStep(100); slider->setTickPosition(QSlider::TicksBelow); auto setScaleOrigin = [=]() { if (proxy) { QPointF position = proxy->mapFromScene(mapToScene(viewport()->rect().center())); if (proxy->rect().contains(position)) proxy->setTransformOriginPoint(position); } }; auto calculateScale = [=](int sliderValue) { if (sliderValue >= 0) { qreal newScale = 1.0 + 0.01 * sliderValue; if (!qFuzzyCompare(newScale, currentScaleFactor())) { setScaleOrigin(); setScaleFactor(1.0 + 0.01 * sliderValue); label->setText(QString("%1%").arg(100 + sliderValue)); } } else { qreal newScale = qPow(MIN_SCALE_FACTOR, -sliderValue / internalFactor / MIN_SCALE_FACTOR); if (!qFuzzyCompare(newScale, currentScaleFactor())) { setScaleOrigin(); setScaleFactor(newScale); label->setText(QString("%1%").arg(newScale * 100, 0, 'f', 1)); } } }; auto calculateValue = [=](qreal scaleFactor) { slider->blockSignals(true); if (scaleFactor >= 1.0) { int newValue = 100 * scaleFactor - 100; if (newValue != slider->value()) { slider->setValue(newValue); label->setText(QString("%1%").arg(qFloor(100 * scaleFactor))); } } else { int newValue = -internalFactor * MIN_SCALE_FACTOR / qLn(MIN_SCALE_FACTOR) * qLn(scaleFactor); if (newValue != slider->value()) { slider->setValue(newValue); label->setText(QString("%1%").arg(100 * scaleFactor, 0, 'f', 1)); } } slider->blockSignals(false); }; connect(slider, &QSlider::valueChanged, calculateScale); connect(this, &CanvasContainer::scaled, calculateValue); } return scaleSliderWidget;}
开发者ID:leosama,项目名称:painttyWidget,代码行数:85,
示例19: viewportvoid UIDisasm::setSelectionColor(const QColor &color){ selectionColor = color; viewport()->update();}
开发者ID:GPDP2,项目名称:yabause,代码行数:5,
示例20: horizontalScrollBarQRectF View::visibleRect(){ int h = horizontalScrollBar() ? horizontalScrollBar()->height() : 0; int w = verticalScrollBar() ? verticalScrollBar()->width() : 0; return mapToScene(viewport()->rect().adjusted(0,0,-w,-h)).boundingRect();}
开发者ID:JurajKubelka,项目名称:Envision,代码行数:6,
示例21: select_dcvoid ProfileGraphicsView::plot(struct dive *d, bool forceRedraw){ struct divecomputer *dc; if (d) dc = select_dc(&d->dc); if (!forceRedraw && dive == d && (d && dc == diveDC)) return; clear(); dive = d; diveDC = d ? dc : NULL; if (!isVisible() || !dive) { return; } // best place to put the focus stealer code. setFocusProxy(mainWindow()->dive_list()); scene()->setSceneRect(0,0, viewport()->width()-50, viewport()->height()-50); toolTip = new ToolTipItem(); installEventFilter(toolTip); scene()->addItem(toolTip); // Fix this for printing / screen later. // plot_set_scale(scale_mode_t); if (!dc->samples) { dc = fake_dc(dc); } QString nick = get_dc_nickname(dc->model, dc->deviceid); if (nick.isEmpty()) nick = QString(dc->model); if (nick.isEmpty()) nick = tr("unknown divecomputer"); if ( tr("unknown divecomputer") == nick){ mode = PLAN; }else{ mode = DIVE; } /* * Set up limits that are independent of * the dive computer */ calculate_max_limits(dive, dc, &gc); QRectF profile_grid_area = scene()->sceneRect(); gc.maxx = (profile_grid_area.width() - 2 * profile_grid_area.x()); gc.maxy = (profile_grid_area.height() - 2 * profile_grid_area.y()); /* This is per-dive-computer */ gc.pi = *create_plot_info(dive, dc, &gc); /* Bounding box */ QPen pen = defaultPen; pen.setColor(profile_color[TIME_GRID].at(0)); QGraphicsRectItem *rect = new QGraphicsRectItem(profile_grid_area); rect->setPen(pen); scene()->addItem(rect); /* Depth profile */ plot_depth_profile(); plot_events(dc); /* Temperature profile */ plot_temperature_profile(); /* Cylinder pressure plot */ plot_cylinder_pressure(dc); /* Text on top of all graphs.. */ plot_temperature_text(); plot_depth_text(); plot_cylinder_pressure_text(); plot_deco_text(); /* Put the dive computer name in the lower left corner */ gc.leftx = 0; gc.rightx = 1.0; gc.topy = 0; gc.bottomy = 1.0; text_render_options_t computer = {DC_TEXT_SIZE, TIME_TEXT, LEFT, TOP}; diveComputer = plot_text(&computer, QPointF(gc.leftx, gc.bottomy), nick); // The Time ruler should be right after the DiveComputer: timeMarkers->setPos(0, diveComputer->y()); if (PP_GRAPHS_ENABLED) { plot_pp_gas_profile(); plot_pp_text(); }//.........这里部分代码省略.........
开发者ID:kuldipem,项目名称:subsurface,代码行数:101,
注:本文中的viewport函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ vif_to_intf函数代码示例 C++ viewer函数代码示例 |