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


C++ QSize::isValid方法代码示例

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


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

示例1: requestPixmap

    QPixmap GlobalImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
    {
        QPixmap image(id);
        QPixmap result;

        if (requestedSize.isValid()) {
            result = image.scaled(requestedSize, Qt::KeepAspectRatio, Qt::SmoothTransformation);
        }
        else {
            result = image;
        }

        *size = result.size();
        return result;
    }
开发者ID:snikolau,项目名称:xpiks,代码行数:15,代码来源:globalimageprovider.cpp

示例2: requestPixmap

QPixmap ItemLibraryImageProvider::requestPixmap(const QString &id, QSize *size, const QSize &requestedSize)
{
    QPixmap pixmap(id);
    if (size) {
        size->setWidth(pixmap.width());
        size->setHeight(pixmap.height());
    }

    if (pixmap.isNull())
        return pixmap;

    if (requestedSize.isValid())
        return pixmap.scaled(requestedSize);
    return pixmap;
}
开发者ID:ProDataLab,项目名称:qt-creator,代码行数:15,代码来源:itemlibraryimageprovider.cpp

示例3: maxMinimumSizeHint

/******************************************************************************
* Return the maximum minimum size for any instance.
*/
QSize StackedScrollGroup::maxMinimumSizeHint() const
{
    QSize sz;
    for (int i = 0, count = mWidgets.count();  i < count;  ++i)
    {
        QWidget* w = static_cast<StackedScrollWidget*>(mWidgets[i])->widget();
        if (!w)
            return QSize();
        QSize s = w->minimumSizeHint();
        if (!s.isValid())
            return QSize();
        sz = sz.expandedTo(s);
    }
    return sz;
}
开发者ID:chusopr,项目名称:kdepim-ktimetracker-akonadi,代码行数:18,代码来源:stackedwidgets.cpp

示例4: restoreWindowSize

void KNHelper::restoreWindowSize(const QString &name, QWidget *d, const QSize &defaultSize)
{
    KConfig *c = knGlobals.config();
    c->setGroup("WINDOW_SIZES");

    QSize s = c->readSizeEntry(name, &defaultSize);

    if(s.isValid())
    {
        QRect max = KGlobalSettings::desktopGeometry(QCursor::pos());
        if(s.width() > max.width()) s.setWidth(max.width() - 5);
        if(s.height() > max.height()) s.setHeight(max.height() - 5);
        d->resize(s);
    }
}
开发者ID:serghei,项目名称:kde3-kdepim,代码行数:15,代码来源:utilities.cpp

示例5: validatePage

bool ConverterWizard::validatePage()
{
	QImageReader reader(m_heightMap->text());
	if ( !reader.canRead() )
		QMessageBox::warning(this, tr("Error"), tr("Can not read heightmap %1 !\n%2").arg(m_heightMap->text()).arg(reader.errorString()));
	else
	{
		QSize size = reader.size();
		if (size.isValid() && ( size.width() != size.height() || ( ( size.width() & ( size.width() - 1 ) ) != 0 ) ) )
			QMessageBox::warning(this, tr("Error"), tr("The heightmap must have equal width and height and the side length must be a power of two! e.g. 1024x1024"));
		else
			return true;
	}
	return false;
}
开发者ID:algts,项目名称:Horde3D,代码行数:15,代码来源:ConverterWizard.cpp

示例6: qwtScreenResolution

static inline QSize qwtScreenResolution()
{
    static QSize screenResolution;
    if ( !screenResolution.isValid() )
    {
        QDesktopWidget *desktop = QApplication::desktop();
        if ( desktop )
        {
            screenResolution.setWidth( desktop->logicalDpiX() );
            screenResolution.setHeight( desktop->logicalDpiY() );
        }
    }

    return screenResolution;
}
开发者ID:FabianFrancoRoldan,项目名称:OpenPilot,代码行数:15,代码来源:qwt_painter.cpp

示例7: pixmapFromSvg

QPixmap BitmapFactoryInst::pixmapFromSvg(const QByteArray& contents, const QSize& size) const
{
#ifdef QTWEBKIT
    QWebView webView;
    QPalette pal = webView.palette();
    pal.setColor(QPalette::Background, Qt::transparent);
    webView.setPalette(pal);
    webView.setContent(contents, QString::fromAscii("image/svg+xml"));
    QString node = QString::fromAscii("document.rootElement.nodeName");
    QString root = webView.page()->mainFrame()->evaluateJavaScript(node).toString();
    if (root.isEmpty() || root.compare(QLatin1String("svg"), Qt::CaseInsensitive)) {
        return QPixmap();
    }

    QString w = QString::fromAscii("document.rootElement.width.baseVal.value");
    QString h = QString::fromAscii("document.rootElement.height.baseVal.value");
    double ww = webView.page()->mainFrame()->evaluateJavaScript(w).toDouble();
    double hh = webView.page()->mainFrame()->evaluateJavaScript(h).toDouble();
    if (ww == 0.0 || hh == 0.0)
        return QPixmap();
#endif

    QImage image(size, QImage::Format_ARGB32_Premultiplied);
    image.fill(0x00000000);

    QPainter p(&image);
#ifdef QTWEBKIT
    qreal xs = size.isValid() ? size.width() / ww : 1.0;
    qreal ys = size.isValid() ? size.height() / hh : 1.0;
    p.scale(xs, ys);

    // the best quality
    p.setRenderHint(QPainter::Antialiasing);
    p.setRenderHint(QPainter::TextAntialiasing);
    p.setRenderHint(QPainter::SmoothPixmapTransform);
    p.setOpacity(0); // important to keep transparent background
    webView.page()->mainFrame()->render(&p);
#else
    // tmp. disable the report window to suppress some bothering warnings
    Base::Console().SetEnabledMsgType("ReportOutput", ConsoleMsgType::MsgType_Wrn, false);
    QSvgRenderer svg(contents);
    Base::Console().SetEnabledMsgType("ReportOutput", ConsoleMsgType::MsgType_Wrn, true);
    svg.render(&p);
#endif
    p.end();

    return QPixmap::fromImage(image);
}
开发者ID:lainegates,项目名称:FreeCAD,代码行数:48,代码来源:BitmapFactory.cpp

示例8: render

/*!
  Render the SVG data

  \param painter Painter
  \param viewBox View Box, see QSvgRenderer::viewBox
  \param rect Traget rectangle on the paint device
*/
void QwtPlotSvgItem::render(QPainter *painter,
        const QRect &viewBox, const QRect &rect) const
{
    if ( !viewBox.isValid() )
        return;

#if QT_VERSION >= 0x040100
    const QSize paintSize(painter->window().width(),
        painter->window().height());
    if ( !paintSize.isValid() )
        return;

    const double xRatio =
        double(paintSize.width()) / viewBox.width();
    const double yRatio =
        double(paintSize.height()) / viewBox.height();

    const double dx = rect.left() / xRatio + 1.0;
    const double dy = rect.top() / yRatio + 1.0;

    const double mx = double(rect.width()) / paintSize.width();
    const double my = double(rect.height()) / paintSize.height();

    painter->save();

    painter->translate(dx, dy);
    painter->scale(mx, my);

    d_data->renderer.setViewBox(viewBox);
    d_data->renderer.render(painter);

    painter->restore();
#else
    const double mx = double(rect.width()) / viewBox.width();
    const double my = double(rect.height()) / viewBox.height();
    const double dx = rect.x() - mx * viewBox.x();
    const double dy = rect.y() - my * viewBox.y();

    painter->save();

    painter->translate(dx, dy);
    painter->scale(mx, my);
    
    d_data->picture.play(painter);

    painter->restore();
#endif
}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:55,代码来源:qwt_plot_svgitem.cpp

示例9: Show

void QuickEdit::Show(BrowserNode * node)
{
    //first, we need to determine the type of currently selected item
    // if we cannot open window for such node type - do nothing
    rootInterface->removeChildren(0, rootInterface->childCount());
    localNodeHolder.clear();
    if(!node)
        return;
    UmlCode nodeType = node->get_type();
    if(!validTypes.contains(nodeType))
        return;
    //next we need to recursively create items for node
    if(!itemCreators.contains(nodeType))
        return;
    itemCreators[nodeType](rootInterface, node);
    // we then assign items and all is ok
    treeModel->InsertRootItem(rootInterface);

    std::function<bool(TreeItemInterface*)> check = [&](TreeItemInterface* )
    {
       return true;
    };

    TreeFunctions::ExpandAllSatisfying<TreeItemInterface>(check, ui->tvEditor, treeModel, QModelIndex());
    QSettings settings(QSettings::IniFormat, QSettings::UserScope, "DoUML", "settings");
    settings.setIniCodec(QTextCodec::codecForName("UTF-8"));
    QByteArray arr = settings.value("headers/quickedit", QByteArray()).toByteArray();
    if(!arr.isNull())
        ui->tvEditor->header()->restoreState(arr);

    ui->chkCpp->setChecked(settings.value("quickedit_checkboxes/cpp",true).toBool());
    ui->chkJava->setChecked(settings.value("quickedit_checkboxes/java", true).toBool());
    ui->chkPhp->setChecked(settings.value("quickedit_checkboxes/php",true).toBool());
    ui->chkPython->setChecked(settings.value("quickedit_checkboxes/python", true).toBool());
    ui->chkIdl->setChecked(settings.value("quickedit_checkboxes/idl", true).toBool());
    QSize size = settings.value("window/size", QSize()).toSize();

    CheckColumnVisibility();
    if(!size.isValid())
        this->showMaximized();
    else
    {
        this->resize(size);
        this->show();
    }


}
开发者ID:open-src,项目名称:douml,代码行数:48,代码来源:quickedit.cpp

示例10: setSize

void QCamFrameCommon::setSize(QSize s) {
   assert(nbRef_<=1);
   if (!s.isValid()) {
      return;
   }
   /* need multiple of 4 */
   int x=s.width();
   int y=s.height();
   if (x%4) {x+=(4-x%4);}
   if (y%4) {y+=(4-y%4);}
   s=QSize(x,y);
   if (size_ != s) {
      size_=s;
      allocBuff();
   }
}
开发者ID:thx8411,项目名称:qastrocam-g2,代码行数:16,代码来源:QCamFrame.cpp

示例11: requestImage

QImage QtImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
{
	if (size != nullptr)
	{
		*size = requestedSize;
	}

	auto key = id.toLongLong();
	auto it = imageCache_.find(key);
	if (it == imageCache_.end())
	{
		return QImage(requestedSize.width(), requestedSize.height(), QImage::Format_ARGB32);
	}

	return requestedSize.isValid() ? it.value().scaled(requestedSize) : it.value();
}
开发者ID:wgsyd,项目名称:wgtf,代码行数:16,代码来源:qt_image_provider.cpp

示例12: clampedBoundingBox

    QSize PagerPrivate::clampedBoundingBox(bool ignoreScrollBars)
    {
        QSize requestedSize = pager->boundingBox();
        int maxHeight = pager->height() - marginTop - marginBottom - (drawLabels ? 12 : 0);
        if (!ignoreScrollBars && orientation == Qt::Horizontal && scrollBar->isVisible()) { maxHeight -= scrollBar->height(); }
        int maxWidth = pager->width() - marginLeft - marginRight;
        if (!ignoreScrollBars && orientation == Qt::Vertical && scrollBar->isVisible()) { maxWidth -= scrollBar->width(); }

        if (!requestedSize.isValid())
        {
            requestedSize = QSize(1, 1);
        }

        requestedSize.scale(maxWidth, maxHeight, Qt::KeepAspectRatio);
        return requestedSize;
    }
开发者ID:project-renard-survey,项目名称:utopia-documents-mirror,代码行数:16,代码来源:pager.cpp

示例13: updateWallpaper

// really generate the background pixmap according to current settings and apply it.
void DesktopWindow::updateWallpaper() {
    if(wallpaperMode_ != WallpaperNone) {  // use wallpaper
        QPixmap pixmap;
        QImage image;
        if(wallpaperMode_ == WallpaperTile) { // use the original size
            image = QImage(wallpaperFile_);
            // Note: We can't use the QPainter::drawTiledPixmap(), because it doesn't tile
            // correctly for background pixmaps bigger than the current screen size.
            const QSize s = size();
            pixmap = QPixmap{s};
            QPainter painter{&pixmap};
            for (int x = 0; x < s.width(); x += image.width()) {
                for (int y = 0; y < s.height(); y += image.height()) {
                    painter.drawImage(x, y, image);
                }
            }
        }
        else if(wallpaperMode_ == WallpaperStretch) {
            image = loadWallpaperFile(size());
            pixmap = QPixmap::fromImage(image);
        }
        else { // WallpaperCenter || WallpaperFit
            if(wallpaperMode_ == WallpaperCenter) {
                image = QImage(wallpaperFile_); // load original image
            }
            else if(wallpaperMode_ == WallpaperFit || wallpaperMode_ == WallpaperZoom) {
                // calculate the desired size
                QSize origSize = QImageReader(wallpaperFile_).size(); // get the size of the original file
                if(origSize.isValid()) {
                    QSize desiredSize = origSize;
                    Qt::AspectRatioMode mode = (wallpaperMode_ == WallpaperFit ? Qt::KeepAspectRatio : Qt::KeepAspectRatioByExpanding);
                    desiredSize.scale(width(), height(), mode);
                    image = loadWallpaperFile(desiredSize); // load the scaled image
                }
            }
            if(!image.isNull()) {
                pixmap = QPixmap(size());
                QPainter painter(&pixmap);
                pixmap.fill(bgColor_);
                int x = (width() - image.width()) / 2;
                int y = (height() - image.height()) / 2;
                painter.drawImage(x, y, image);
            }
        }
        wallpaperPixmap_ = pixmap;
    }
}
开发者ID:SafaAlfulaij,项目名称:pcmanfm-qt,代码行数:48,代码来源:desktopwindow.cpp

示例14: requestImage

QImage WindowImageProvider::requestImage(const QString &id,
                                              QSize *size,
                                              const QSize &requestedSize)
{
    /* Throw away the part of the id after the @ (if any) since it's just a timestamp
       added to force the QML image cache to request to this image provider
       a new image instead of re-using the old. See SpreadWindow.qml for more
       details on the problem. */
    int atPos = id.indexOf('@');
    QString windowIds = (atPos == -1) ? id : id.left(atPos);

    /* After doing this, split the rest of the id on the character "|". The first
       part is the window ID of the decorations, the latter of the actual content. */
    atPos = windowIds.indexOf('|');
    Window frameId = ((atPos == -1) ? windowIds : windowIds.left(atPos)).toULong();
    Window contentId = ((atPos == -1) ? windowIds : windowIds.mid(atPos + 1)).toULong();

    /* Use form image://window/root to specify you want an image of the root window */
    if (atPos == -1 && windowIds == "root") {
        frameId = QX11Info::appRootWindow();
    }

    QImage image;
    QPixmap pixmap = getWindowPixmap(frameId, contentId);
    if (!pixmap.isNull()) {
        image = convertWindowPixmap(pixmap, frameId);
        if (image.isNull()) {
            /* This means that the window got unmapped while we were converting it to
               an image. Try again so that we will pick up the pixmap captured by
               metacity instead. */
            pixmap = getWindowPixmap(frameId, contentId);
            if (!pixmap.isNull()) {
                image = convertWindowPixmap(pixmap, frameId);
            }
        }
    }

    if (!image.isNull()) {
        if (requestedSize.isValid()) {
            image = image.scaled(requestedSize);
        }
        size->setWidth(image.width());
        size->setHeight(image.height());
    }

    return image;
}
开发者ID:davecahill,项目名称:unity-2d-for-xmonad,代码行数:47,代码来源:windowimageprovider.cpp

示例15: newSurfaceCreated

void QWaylandEglWindow::newSurfaceCreated()
{
    if (mWaylandEglWindow) {
        wl_egl_window_destroy(mWaylandEglWindow);
    }
    wl_visual *visual = QWaylandScreen::waylandScreenFromWidget(widget())->visual();
    QSize size = geometry().size();
    if (!size.isValid())
        size = QSize(0,0);

    mWaylandEglWindow = wl_egl_window_create(mSurface,size.width(),size.height(),visual);
    if (mGLContext) {
        EGLNativeWindowType window(reinterpret_cast<EGLNativeWindowType>(mWaylandEglWindow));
        EGLSurface surface = eglCreateWindowSurface(mEglIntegration->eglDisplay(),mGLContext->eglConfig(),window,NULL);
        mGLContext->setEglSurface(surface);
    }
}
开发者ID:wpbest,项目名称:copperspice,代码行数:17,代码来源:qwaylandeglwindow.cpp


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