本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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;
}
示例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;
}
示例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);
}
示例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
}
示例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();
}
}
示例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();
}
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
}