本文整理汇总了C++中QRect::getRect方法的典型用法代码示例。如果您正苦于以下问题:C++ QRect::getRect方法的具体用法?C++ QRect::getRect怎么用?C++ QRect::getRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QRect
的用法示例。
在下文中一共展示了QRect::getRect方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: operator
bool operator()(unsigned int a, unsigned int b) {
QDesktopWidget qdw;
QRect rectA = qdw.screenGeometry(a);
QRect rectB = qdw.screenGeometry(b);
int x, y, width, height;
rectA.getRect(&x, &y, &width, &height);
rectB.getRect(&x, &y, &width, &height);
if (_isQTIndexDisorder) // means
return !(rectB.x() > rectA.x());
else
return (rectB.x() > rectA.x());
}
示例2: p
QPixmap
FX::applyAlpha(const QPixmap &toThisPix, const QPixmap &fromThisPix, const QRect &rect, const QRect &alphaRect)
{
QPixmap pix;
int sx,sy,ax,ay,w,h;
if (rect.isNull())
{ sx = sy = 0; w = toThisPix.width(); h = toThisPix.height(); }
else
rect.getRect(&sx,&sy,&w,&h);
if (alphaRect.isNull())
{ ax = ay = 0; }
else
{
ax = alphaRect.x(); ay = alphaRect.y();
w = qMin(alphaRect.width(),w); h = qMin(alphaRect.height(),h);
}
if (w > fromThisPix.width() || h > fromThisPix.height())
pix = QPixmap(w, h);
else
pix = fromThisPix.copy(0,0,w,h); // cause slow depth conversion...
pix.fill(Qt::transparent);
QPainter p(&pix);
p.drawPixmap(0, 0, toThisPix, sx, sy, w, h);
p.setCompositionMode(QPainter::CompositionMode_DestinationIn);
p.drawPixmap(0, 0, fromThisPix, ax, ay, w, h);
p.end();
return pix;
}
示例3: drawDebugRect
void QDirectFbBlitter::drawDebugRect(const QRect &rect, const QColor &color)
{
int x, y, w, h;
DFBResult result;
// check parameters
rect.getRect(&x, &y ,&w, &h);
if ((w <= 0) || (h <= 0)) return;
m_surface->SetDrawingFlags(m_surface.data(),
DFBSurfaceDrawingFlags(m_premult ? (DSDRAW_BLEND | DSDRAW_SRC_PREMULTIPLY) : DSDRAW_BLEND));
m_surface->SetPorterDuff(m_surface.data(), DSPD_SRC_OVER);
// set color
m_surface->SetColor(m_surface.data(), color.red(), color.green(), color.blue(), 120);
result = m_surface->DrawLine(m_surface.data(), x, y, x + w-1, y);
if (result != DFB_OK)
DirectFBError("QDirectFBBlitter::drawDebugRect()", result);
result = m_surface->DrawLine(m_surface.data(), x + w-1, y, x + w-1, y + h-1);
if (result != DFB_OK)
DirectFBError("QDirectFBBlitter::drawDebugRect()", result);
result = m_surface->DrawLine(m_surface.data(), x + w-1, y + h-1, x, y + h-1);
if (result != DFB_OK)
DirectFBError("QDirectFBBlitter::drawDebugRect()", result);
result = m_surface->DrawLine(m_surface.data(), x, y + h-1, x, y);
if (result != DFB_OK)
DirectFBError("QDirectFBBlitter::drawDebugRect()", result);
m_surface->SetColor(m_surface.data(), color.red(), color.green(), color.blue(), 10);
result = m_surface->FillRectangle(m_surface.data(), x, y, w, h);
if (result != DFB_OK)
DirectFBError("QDirectFBBlitter::drawDebugRect()", result);
}
示例4: paintEvent
void QColorButton::paintEvent (QPaintEvent *p)
{
QPushButton::paintEvent (p);
QStyleOptionButton option;
option.initFrom (this);
int x, y, w, h;
QRect r = style()->subElementRect (QStyle::SE_PushButtonContents, &option, this);
r.getRect (&x, &y, &w, &h);
int margin = style()->pixelMetric (QStyle::PM_ButtonMargin, &option, this);
x += margin;
y += margin;
w -= 2*margin;
h -= 2*margin;
if (isChecked() || isDown()) {
x += style()->pixelMetric (QStyle::PM_ButtonShiftHorizontal, &option, this );
y += style()->pixelMetric (QStyle::PM_ButtonShiftVertical, &option, this );
}
QPainter painter (this);
QColor fillCol = isEnabled() ? col : palette().brush(QPalette::Window).color();
qDrawShadePanel (&painter, x, y, w, h, palette(), true, 1, NULL);
if (fillCol.isValid())
painter.fillRect (x+1, y+1, w-2, h-2, fillCol);
if (hasFocus()) {
style()->subElementRect (QStyle::SE_PushButtonFocusRect, &option, this);
style()->drawPrimitive (QStyle::PE_FrameFocusRect, &option, &painter, this);
}
}
示例5: paintEvent
void QColorButton::paintEvent( QPaintEvent * event )
{
QPainter painter( this );
int x, y, w, h;
QStyleOptionButton opt;
opt.rect = event->rect();
style()->drawControl(QStyle::CE_PushButtonBevel, &opt, &painter, this);
QRect r = style()->subElementRect( QStyle::SE_PushButtonContents, &opt, this );
r.getRect(&x, &y, &w, &h);
//int margin = style()->pixelMetric( QStyle::PM_ButtonMargin, &opt, this );
//x += margin;
//y += margin;
//w -= 2*margin;
//h -= 2*margin;
//if (isOn() || isDown()) {
// x += style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal, &opt, this );
// y += style()->pixelMetric( QStyle::PM_ButtonShiftVertical, &opt, this );
//}
const QColor fillCol = isEnabled() ? col : palette().background().color();
qDrawShadePanel( &painter, x, y, w, h, palette(), true, 1, NULL);
if ( fillCol.isValid() )
painter.fillRect( x+1, y+1, w-2, h-2, fillCol );
//if ( hasFocus() ) {
// QRect focusRect = style()->subElementRect( QStyle::SE_PushButtonFocusRect, &opt, this );
// style()->drawPrimitive( QStyle::PE_FrameFocusRect, &opt, &painter, this );
//}
}
示例6: setGeometry
void QSFMLCanvas::setGeometry(QRect rect)
{
int x, y, width, height;
rect.getRect(&x, &y, &width, &height);
move(QPoint(x,y));
resize(QSize(width, height));
}
示例7: convertToQImageFast
QImage KisImagePyramid::convertToQImageFast(KisPaintDeviceSP paintDevice,
const QRect& unscaledRect)
{
qint32 x, y, w, h;
unscaledRect.getRect(&x, &y, &w, &h);
QImage image = QImage(w, h, QImage::Format_ARGB32);
paintDevice->dataManager()->readBytes(image.bits(), x, y, w, h);
return image;
}
示例8: decoRoundedMask
//_______________________________________________________________________
QRegion DecoHelper::decoRoundedMask( const QRect& r, int left, int right, int top, int bottom ) const
{
// get rect geometry
int x, y, w, h;
r.getRect(&x, &y, &w, &h);
QRegion mask(x + 3*left, y + 0*top, w-3*(left+right), h-0*(top+bottom));
mask += QRegion(x + 0*left, y + 3*top, w-0*(left+right), h-3*(top+bottom));
mask += QRegion(x + 1*left, y + 1*top, w-1*(left+right), h-1*(top+bottom));
return mask;
}
示例9: setROI
void QArvCamera::setROI(QRect roi) {
int x, y, width, height;
roi.getRect(&x, &y, &width, &height);
auto hmin = getROIHeightBounds();
auto wmin = getROIWidthBounds();
arv_device_set_integer_feature_value(device, "Width", wmin.first);
arv_device_set_integer_feature_value(device, "Height", hmin.first);
arv_device_set_integer_feature_value(device, "OffsetX", x);
arv_device_set_integer_feature_value(device, "OffsetY", y);
arv_device_set_integer_feature_value(device, "Width", width);
arv_device_set_integer_feature_value(device, "Height", height);
emit dataChanged(QModelIndex(), QModelIndex());
}
示例10: QRect
QRect KisImagePyramid::downsampleByFactor2(const QRect& srcRect,
KisPaintDevice* src,
KisPaintDevice* dst)
{
qint32 srcX, srcY, srcWidth, srcHeight;
srcRect.getRect(&srcX, &srcY, &srcWidth, &srcHeight);
alignRectBy2(srcX, srcY, srcWidth, srcHeight);
// Nothing to do
if (srcWidth < 1) return QRect();
if (srcHeight < 1) return QRect();
qint32 dstX = srcX / 2;
qint32 dstY = srcY / 2;
qint32 dstWidth = srcWidth / 2;
qint32 dstHeight = srcHeight / 2;
KisHLineConstIteratorSP srcIt0 = src->createHLineConstIteratorNG(srcX, srcY, srcWidth);
KisHLineConstIteratorSP srcIt1 = src->createHLineConstIteratorNG(srcX, srcY + 1, srcWidth);
KisHLineIteratorSP dstIt = dst->createHLineIteratorNG(dstX, dstY, dstWidth);
int conseqPixels = 0;
for (int row = 0; row < dstHeight; ++row) {
do {
int srcItConseq = srcIt0->nConseqPixels();
int dstItConseq = dstIt->nConseqPixels();
conseqPixels = qMin(srcItConseq, dstItConseq * 2);
Q_ASSERT(!isOdd(conseqPixels));
downsamplePixels(srcIt0->oldRawData(), srcIt1->oldRawData(),
dstIt->rawData(), conseqPixels);
srcIt1->nextPixels(conseqPixels);
dstIt->nextPixels(conseqPixels / 2);
} while (srcIt0->nextPixels(conseqPixels));
srcIt0->nextRow();
srcIt0->nextRow();
srcIt1->nextRow();
srcIt1->nextRow();
dstIt->nextRow();
}
return QRect(dstX, dstY, dstWidth, dstHeight);
}
示例11: QRect
QRect KisImagePyramid::downsampleByFactor2(const QRect& srcRect,
KisPaintDevice* src,
KisPaintDevice* dst)
{
qint32 srcX, srcY, srcWidth, srcHeight;
srcRect.getRect(&srcX, &srcY, &srcWidth, &srcHeight);
alignRectBy2(srcX, srcY, srcWidth, srcHeight);
qint32 dstX = srcX / 2;
qint32 dstY = srcY / 2;
qint32 dstWidth = srcWidth / 2;
qint32 dstHeight = srcHeight / 2;
KisHLineConstIteratorPixel srcIt0 = src->createHLineConstIterator(srcX, srcY, srcWidth);
KisHLineConstIteratorPixel srcIt1 = src->createHLineConstIterator(srcX, srcY + 1, srcWidth);
KisHLineIteratorPixel dstIt = dst->createHLineIterator(dstX, dstY, dstWidth);
for (int row = 0; row < dstHeight; ++row) {
while (!dstIt.isDone()) {
int srcItConseq = srcIt0.nConseqHPixels();
int dstItConseq = dstIt.nConseqHPixels();
int conseqPixels = qMin(srcItConseq, dstItConseq * 2);
Q_ASSERT(!isOdd(conseqPixels));
downsamplePixels(srcIt0.rawData(), srcIt1.rawData(),
dstIt.rawData(), conseqPixels);
srcIt0 += conseqPixels;
srcIt1 += conseqPixels;
dstIt += conseqPixels / 2;
}
srcIt0.nextRow();
srcIt0.nextRow();
srcIt1.nextRow();
srcIt1.nextRow();
dstIt.nextRow();
}
return QRect(dstX, dstY, dstWidth, dstHeight);
}
示例12: paintEvent
void ColorButton::paintEvent( QPaintEvent * )
{
QPainter painter(this);
//First, we need to draw the bevel.
QStyleOptionButton butOpt;
initStyleOption(&butOpt);
style()->drawControl( QStyle::CE_PushButtonBevel, &butOpt, &painter, this );
//OK, now we can muck around with drawing out pretty little color box
//First, sort out where it goes
QRect labelRect = style()->subElementRect( QStyle::SE_PushButtonContents,
&butOpt, this );
int shift = style()->pixelMetric( QStyle::PM_ButtonMargin );
labelRect.adjust(shift, shift, -shift, -shift);
int x, y, w, h;
labelRect.getRect(&x, &y, &w, &h);
if (isChecked() || isDown()) {
x += style()->pixelMetric( QStyle::PM_ButtonShiftHorizontal );
y += style()->pixelMetric( QStyle::PM_ButtonShiftVertical );
}
QColor fillCol = isEnabled() ? btnColor : palette().color(backgroundRole());
qDrawShadePanel( &painter, x, y, w, h, palette(), true, 1, NULL);
if ( fillCol.isValid() )
painter.fillRect( x+1, y+1, w-2, h-2, fillCol );
if ( hasFocus() ) {
QRect focusRect = style()->subElementRect( QStyle::SE_PushButtonFocusRect, &butOpt, this );
QStyleOptionFocusRect focusOpt;
focusOpt.init(this);
focusOpt.rect = focusRect;
focusOpt.backgroundColor = palette().background().color();
style()->drawPrimitive( QStyle::PE_FrameFocusRect, &focusOpt, &painter, this );
}
}
示例13: QWidget
robotViz::robotViz(QWidget *parent) :
QWidget(parent),
ui(new Ui::robotViz)
{
ui->setupUi(this);
// ui->customPlot=new Qui->customPlot;
QRect rec = QApplication::desktop()->screenGeometry();
int x[1],y[1],w[1],h[1];
rec.getRect(x,y,w,h);
setGeometry(x[0]+150,y[0]+25,640,480);
// give the axes some labels:
ui->customPlot->xAxis->setLabel("x");
ui->customPlot->yAxis->setLabel("y");
// set axes ranges, so we see all data:
ui->customPlot->xAxis->setRange(-MAX_AREA/2, MAX_AREA);
ui->customPlot->yAxis->setRange(-MAX_AREA/2, MAX_AREA);
ui->customPlot->setBackground(Qt::transparent);
ui->customPlot->setAttribute(Qt::WA_OpaquePaintEvent, false);
ui->customPlot->addGraph(); // red line for traj
ui->customPlot->graph(0)->setPen(QPen(Qt::red,2));
ui->customPlot->addGraph(); // blue dot robot position
ui->customPlot->graph(1)->setPen(QPen(Qt::blue,2));
ui->customPlot->graph(1)->setLineStyle(QCPGraph::lsNone);
ui->customPlot->graph(1)->setScatterStyle(QCPScatterStyle::ssDisc);
ui->customPlot->addGraph(); // blue dot robot position
ui->customPlot->graph(2)->setPen(QPen(QColor(255, 100, 0),2));
ui->customPlot->graph(2)->setLineStyle(QCPGraph::lsNone);
ui->customPlot->graph(2)->setScatterStyle(QCPScatterStyle::ssDisc);
}
示例14: paintEvent
void ScrollZoomWidget::paintEvent(QPaintEvent * /*paintEvent*/, QPainter & painter)
{
//draw scroll bar
UpdateScrollBarPosition();
//draw slider
UpdateSliderPosition();
painter.setPen(Qt::black);
//draw increase box
{
painter.setPen(Qt::black);
QRect increaseRect = GetIncreaseRect();
painter.drawRect(increaseRect);
int increaseRectX1;
int increaseRectY1;
int increaseRectX2;
int increaseRectY2;
increaseRect.getRect(&increaseRectX1, &increaseRectY1, &increaseRectX2, &increaseRectY2);
int vertLineX1 = increaseRectX1 + increaseRect.width()/2;
int vertLineY1 = increaseRectY1;
int vertLineX2 = vertLineX1;
int vertLineY2 = increaseRectY1+ increaseRectY2;
painter.drawLine(vertLineX1, vertLineY1, vertLineX2, vertLineY2);
int horLineX1 = increaseRectX1 ;
int horLineY1 = increaseRectY1 + increaseRect.height()/2;
int horLineX2 = increaseRectX1 + increaseRectX2;
int horLineY2 = horLineY1;
painter.drawLine(horLineX1, horLineY1, horLineX2, horLineY2);
}
//draw scale value
{
char scaleChar[10];
sprintf(scaleChar, "%.0f", scale * 100);
QString scale(scaleChar);
painter.setPen(Qt::black);
QRect scaleRect(GetScaleRect());
scaleRect.setWidth(SCALE_WIDTH);
painter.drawText(scaleRect.bottomLeft(), scale);
}
//draw decrease box
{
painter.setPen(Qt::black);
QRect decreaseRect = GetDecreaseRect();
painter.drawRect(decreaseRect);
int decreaseRectX1;
int decreaseRectY1;
int decreaseRectX2;
int decreaseRectY2;
decreaseRect.getRect(&decreaseRectX1, &decreaseRectY1, &decreaseRectX2, &decreaseRectY2);
int horLineX1 = decreaseRectX1 ;
int horLineY1 = decreaseRectY1 + decreaseRect.height()/2;
int horLineX2 = decreaseRectX1 + decreaseRectX2;
int horLineY2 = horLineY1;
painter.drawLine(horLineX1, horLineY1, horLineX2, horLineY2);
}
}
示例15: crop
KESM_NAMESPACE_START
bool Cropper::crop(QString imageName, QRect &rect, QString croppedImageName, bool overWrite)
{
if(QFile::exists(croppedImageName) && !overWrite)
{
return false;
}
//////////////
// reader
ReaderType::Pointer reader = ReaderType::New();
reader->SetFileName( imageName.toStdString() );
try
{
reader->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return false; // EXIT_FAILURE;
}
////////////////////////////////////////////
// !!! LowerBoundar is the top left.
// !!! UpperBoundary is the right bottom.
// This is very confusing. This may be a bug.
//////////////////
// get crop size
ImageType::SizeType cropSizeUpper, cropSizeLower;
int x, y, width, height;
rect.getRect(&x, &y, &width, &height);
cropSizeLower[0] = x, cropSizeLower[1] = y;
// get input image size
ImageType::SizeType imageSize = reader->GetOutput()->GetLargestPossibleRegion().GetSize();
cropSizeUpper[0] = imageSize[0]-(width+x);
if(height == -1) // use the image height
cropSizeUpper[1] = 0;
else
cropSizeUpper[1] = imageSize[1]-(height+y);
//////////////
// filter
FilterType::Pointer filter = FilterType::New();
filter->SetInput(reader->GetOutput());
filter->SetUpperBoundaryCropSize(cropSizeUpper);
filter->SetLowerBoundaryCropSize(cropSizeLower);
try
{
filter->Update();
}
catch( itk::ExceptionObject & err )
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return false; // EXIT_FAILURE;
}
WriterType::Pointer writer = WriterType::New();
writer->SetFileName(croppedImageName.toStdString());
writer->SetInput( filter->GetOutput() );
try
{
writer->Update();
}
catch ( itk::ExceptionObject &err)
{
std::cerr << "ExceptionObject caught !" << std::endl;
std::cerr << err << std::endl;
return false;
}
return true;
}