本文整理汇总了C++中QSizeF::setWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ QSizeF::setWidth方法的具体用法?C++ QSizeF::setWidth怎么用?C++ QSizeF::setWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSizeF
的用法示例。
在下文中一共展示了QSizeF::setWidth方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: size
QSizeF CanvasSize::size(SizeUnits unit) const
{
QSizeF result;
result.setWidth( toPixels(m_size.width(), m_resolution.width(), m_size_unit, m_resolution_unit) );
result.setHeight( toPixels(m_size.height(), m_resolution.height(), m_size_unit, m_resolution_unit) );
if (unit != Pixels)
{
result.setWidth( fromPixels(result.width(), m_resolution.width(), unit, m_resolution_unit) );
result.setHeight( fromPixels(result.height(), m_resolution.height(), unit, m_resolution_unit) );
}
return result;
}
示例2: physicalScreenSizeFromFb
QSizeF EglUtils::physicalScreenSizeFromFb(int framebufferDevice, const QSize &screenSize)
{
#ifndef Q_OS_LINUX
Q_UNUSED(framebufferDevice)
#endif
const int defaultPhysicalDpi = 100;
static QSizeF size;
if (size.isEmpty()) {
// Note: in millimeters
int width = qEnvironmentVariableIntValue("GREENISLAND_QPA_PHYSICAL_WIDTH");
int height = qEnvironmentVariableIntValue("GREENISLAND_QPA_PHYSICAL_HEIGHT");
if (width && height) {
size.setWidth(width);
size.setHeight(height);
return size;
}
int w = -1;
int h = -1;
QSize screenResolution;
#ifdef Q_OS_LINUX
struct fb_var_screeninfo vinfo;
if (framebufferDevice != -1) {
if (ioctl(framebufferDevice, FBIOGET_VSCREENINFO, &vinfo) == -1) {
qCWarning(lcEglConvenience, "Could not query screen info");
} else {
w = vinfo.width;
h = vinfo.height;
screenResolution = QSize(vinfo.xres, vinfo.yres);
}
} else
#endif
{
// Use the provided screen size, when available, since some platforms may have their own
// specific way to query it. Otherwise try querying it from the framebuffer.
screenResolution = screenSize.isEmpty() ? screenSizeFromFb(framebufferDevice) : screenSize;
}
size.setWidth(w <= 0 ? screenResolution.width() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
size.setHeight(h <= 0 ? screenResolution.height() * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));
if (w <= 0 || h <= 0)
qCWarning(lcEglConvenience,
"Unable to query physical screen size, defaulting to %d dpi.\n"
"To override, set GREENISLAND_QPA_PHYSICAL_WIDTH "
"and GREENISLAND_QPA_PHYSICAL_HEIGHT (in millimeters).", defaultPhysicalDpi);
}
return size;
}
示例3: targetSize
QSizeF targetSize() const {
QSizeF size = imageData->imageSize();
if (targetImageSizePercent.width() > 0.0)
size.setWidth(0.01 * targetImageSizePercent.width() * size.width());
else if (targetImageSize.width() > 0.0)
size.setWidth(targetImageSize.width());
if (targetImageSizePercent.height() > 0.0)
size.setHeight(0.01 * targetImageSizePercent.height() * size.height());
else if (targetImageSize.height() > 0.0)
size.setHeight(targetImageSize.height());
return size;
}
示例4: physicalScreenSize
QSizeF QEglFSHooks::physicalScreenSize() const
{
static QSizeF size;
if (size.isEmpty()) {
// Note: in millimeters
int width = qgetenv("QT_QPA_EGLFS_PHYSICAL_WIDTH").toInt();
int height = qgetenv("QT_QPA_EGLFS_PHYSICAL_HEIGHT").toInt();
if (width && height) {
// no need to read fb0
size.setWidth(width);
size.setHeight(height);
return size;
}
struct fb_var_screeninfo vinfo;
int w = -1;
int h = -1;
if (framebuffer != -1) {
if (ioctl(framebuffer, FBIOGET_VSCREENINFO, &vinfo) == -1) {
qWarning("EGLFS: Could not query variable screen info.");
} else {
w = vinfo.width;
h = vinfo.height;
}
}
const int defaultPhysicalDpi = 100;
size.setWidth(w <= 0 ? vinfo.xres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(w));
size.setHeight(h <= 0 ? vinfo.yres * Q_MM_PER_INCH / defaultPhysicalDpi : qreal(h));
if (w <= 0 || h <= 0) {
qWarning("EGLFS: Unable to query physical screen size, defaulting to %d dpi.\n"
"EGLFS: To override, set QT_QPA_EGLFS_PHYSICAL_WIDTH "
"and QT_QPA_EGLFS_PHYSICAL_HEIGHT (in millimeters).",
defaultPhysicalDpi);
}
// override fb0 from environment var setting
if (width)
size.setWidth(width);
if (height)
size.setWidth(height);
}
return size;
}
示例5: minimumSizeHint
QSizeF UIGraphicsScrollArea::minimumSizeHint() const
{
/* Minimum size-hint of scroll-bar by default: */
QSizeF msh = m_pScrollBar->minimumSizeHint();
if (m_pViewport)
{
switch (m_enmOrientation)
{
case Qt::Horizontal:
{
/* Expand it with viewport height: */
const int iWidgetHeight = m_pViewport->size().height();
if (msh.height() < iWidgetHeight)
msh.setHeight(iWidgetHeight);
break;
}
case Qt::Vertical:
{
/* Expand it with viewport width: */
const int iWidgetWidth = m_pViewport->size().width();
if (msh.width() < iWidgetWidth)
msh.setWidth(iWidgetWidth);
break;
}
}
}
return msh;
}
示例6: applyViewboxTransformation
void KPathShapePrivate::applyViewboxTransformation(const KXmlElement &element)
{
Q_Q(KPathShape);
// apply viewbox transformation
QRectF viewBox = q->loadOdfViewbox(element);
if (! viewBox.isEmpty()) {
// load the desired size
QSizeF size;
size.setWidth(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "width", QString())));
size.setHeight(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "height", QString())));
// load the desired position
QPointF pos;
pos.setX(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "x", QString())));
pos.setY(KUnit::parseValue(element.attributeNS(KOdfXmlNS::svg, "y", QString())));
// create matrix to transform original path data into desired size and position
QTransform viewMatrix;
viewMatrix.translate(-viewBox.left(), -viewBox.top());
viewMatrix.scale(size.width() / viewBox.width(), size.height() / viewBox.height());
viewMatrix.translate(pos.x(), pos.y());
// transform the path data
map(viewMatrix);
}
}
示例7: loadSizeF
/**
* @brief cwRegionLoadTask::loadSizeF
* @param protoSize
* @return
*/
QSizeF cwRegionLoadTask::loadSizeF(const QtProto::QSizeF &protoSize)
{
QSizeF size;
size.setWidth(protoSize.width());
size.setHeight(protoSize.height());
return size;
}
示例8: updateGeometry
/**
* Reimplemented from UMLWidget::updateGeometry to calculate
* minimum size for signal widget based on the current signal type.
*/
void SignalWidget::updateGeometry()
{
QSizeF minSize = textItemGroupAt(GroupIndex)->minimumSize();
if (minSize.width() < SignalWidget::MinimumSize.width()) {
minSize.setWidth(SignalWidget::MinimumSize.width());
}
if (m_signalType == SignalWidget::Accept) {
// We need 1/3rd part for the '>' shape.(hollow or convex)
minSize.rwidth() += minSize.width() / 3 + margin();
}
else if (m_signalType == SignalWidget::Send) {
// Add one third for the '>' shape.
minSize.rwidth() += minSize.width() / 3 + margin();
}
else if (m_signalType == SignalWidget::Time) {
// In case of SignalWidget::Time add minimum height to
// calculated as the text appears below drawing.
minSize.rheight() += SignalWidget::MinimumSize.height();
}
setMinimumSize(minSize);
UMLWidget::updateGeometry();
}
示例9: createNewFolder
void RightClickStrategy::createNewFolder()
{
FolderShape *fs = new FolderShape();
// TODO show dialog to name the folder
fs->setName("New folder");
if (m_canvas->itemStore()->folders().count() == 1 && m_canvas->itemStore()->folders()[0]->border() == 0) {
// the first new folder, lets be kinds and resize the folders to make it managable for the user.
FolderShape *oldFolder = m_canvas->itemStore()->folders()[0];
oldFolder->update();
oldFolder->setBorder(new FolderBorder());
KInsets insets = oldFolder->insets();
oldFolder->setPosition(QPointF(insets.left, insets.top));
QSizeF size = oldFolder->size(); // we can assume size is the size of the whole widget. So we just make each use half of that.
size.setWidth(size.width() / 2.);
oldFolder->setSize(size);
if (oldFolder->model()->count()) {
// Make sure we don't resize the folder to small for its contents.
QPointF bottom = oldFolder->model()->shapes().last()->absolutePosition(KFlake::BottomRightCorner);
if (bottom.y() > size.height())
oldFolder->setSize(QSizeF(size.width(), bottom.y()));
}
oldFolder->update();
fs->setPosition(QPointF(size.width(), insets.top));
fs->setSize(size);
} else {
fs->setAbsolutePosition(m_lastPosition);
fs->setSize(QSizeF(150, 100));
}
m_canvas->itemStore()->addFolder(fs);
}
示例10: doLayout
qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const
{
qreal left, top, right, bottom;
getContentsMargins(&left, &top, &right, &bottom);
const qreal maxw = geom.width() - left - right;
qreal x = 0;
qreal y = 0;
qreal maxRowHeight = 0;
QSizeF pref;
for (int i = 0; i < m_items.count(); ++i) {
QGraphicsLayoutItem *item = m_items.at(i);
pref = item->effectiveSizeHint(Qt::PreferredSize);
maxRowHeight = qMax(maxRowHeight, pref.height());
qreal next_x;
next_x = x + pref.width();
if (next_x > maxw) {
if (x == 0) {
pref.setWidth(maxw);
} else {
x = 0;
next_x = pref.width();
}
y += maxRowHeight + spacing(Qt::Vertical);
maxRowHeight = 0;
}
if (applyNewGeometry)
item->setGeometry(QRectF(QPointF(left + x, top + y), pref));
x = next_x + spacing(Qt::Horizontal);
}
maxRowHeight = qMax(maxRowHeight, pref.height());
return top + y + maxRowHeight + bottom;
}
示例11: expandSize
static void expandSize(QSizeF &result, const QSizeF &size)
{
if (size.width() >= 0 && size.width() > result.width())
result.setWidth(size.width());
if (size.height() >= 0 && size.height() > result.height())
result.setHeight(size.height());
}
示例12: itemChange
// --------------------------------------------------------------------------------------------------------------------------------------
QVariant CSizeGrip::itemChange(GraphicsItemChange change, const QVariant &value)
{
switch(change)
{
case QGraphicsItem::ItemPositionChange:
{
QPointF nextPos = value.toPointF();
QPointF targetPos = pos() - nextPos;
QSizeF resultSize = gWindow()->size() - QSizeF(targetPos.x(), targetPos.y());
if(resultSize.width() < gWindow()->minSize().width())
{
resultSize.setWidth(gWindow()->minSize().width());
nextPos.setX(pos().x());
}
if(resultSize.height() < gWindow()->minSize().height())
{
resultSize.setHeight(gWindow()->minSize().height());
nextPos.setY(pos().y());
}
gWindow()->setSize(resultSize);
return nextPos;
}
break;
default: return QGraphicsItem::itemChange(change, value);
}
return QGraphicsItem::itemChange(change, value);
}
示例13: combineSize
static void combineSize(QSizeF &result, const QSizeF &size)
{
if (result.width() < 0)
result.setWidth(size.width());
if (result.height() < 0)
result.setHeight(size.height());
}
示例14: readSize
QSizeF readSize(QDomElement e)
{
QSizeF p;
p.setWidth(e.attribute("w", "0.0").toDouble());
p.setHeight(e.attribute("h", "0.0").toDouble());
return p;
}
示例15: _q_updateSize
void QDeclarativeLoaderPrivate::_q_updateSize(bool loaderGeometryChanged)
{
Q_Q(QDeclarativeLoader);
if (!item || updatingSize)
return;
updatingSize = true;
if (QDeclarativeItem *qmlItem = qobject_cast<QDeclarativeItem*>(item)) {
if (!itemWidthValid)
q->setImplicitWidth(qmlItem->implicitWidth());
else
q->setImplicitWidth(qmlItem->width());
if (loaderGeometryChanged && q->widthValid())
qmlItem->setWidth(q->width());
if (!itemHeightValid)
q->setImplicitHeight(qmlItem->implicitHeight());
else
q->setImplicitHeight(qmlItem->height());
if (loaderGeometryChanged && q->heightValid())
qmlItem->setHeight(q->height());
} else if (item && item->isWidget()) {
QGraphicsWidget *widget = static_cast<QGraphicsWidget*>(item);
QSizeF widgetSize = widget->size();
q->setImplicitWidth(widgetSize.width());
if (loaderGeometryChanged && q->widthValid())
widgetSize.setWidth(q->width());
q->setImplicitHeight(widgetSize.height());
if (loaderGeometryChanged && q->heightValid())
widgetSize.setHeight(q->height());
if (widget->size() != widgetSize)
widget->resize(widgetSize);
}
updatingSize = false;
}