Doc: compile separations snippets
Done-with: Nico Vertriest <nico.vertriest@qt.io> Task-number: QTBUG-81486 Change-Id: I62294cedd4a0f96ebc2513b5b4179d451bb4b375 Reviewed-by: Topi Reiniö <topi.reinio@qt.io>
This commit is contained in:
parent
7e571c3927
commit
614ca8ec4a
@ -54,9 +54,16 @@ finalwidget.cpp
|
||||
A widget to display an image and a label containing a description.
|
||||
*/
|
||||
|
||||
#include <QtGui>
|
||||
#include "finalwidget.h"
|
||||
|
||||
#include <QApplication>
|
||||
#include <QBuffer>
|
||||
#include <QDrag>
|
||||
#include <QLabel>
|
||||
#include <QMimeData>
|
||||
#include <QMouseEvent>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
FinalWidget::FinalWidget(QWidget *parent, const QString &name,
|
||||
const QSize &labelSize)
|
||||
: QFrame(parent)
|
||||
@ -96,7 +103,7 @@ void FinalWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
QByteArray output;
|
||||
QBuffer outputBuffer(&output);
|
||||
outputBuffer.open(QIODevice::WriteOnly);
|
||||
imageLabel->pixmap()->toImage().save(&outputBuffer, "PNG");
|
||||
imageLabel->pixmap().toImage().save(&outputBuffer, "PNG");
|
||||
mimeData->setData("image/png", output);
|
||||
//! [0]
|
||||
/*
|
||||
@ -105,13 +112,11 @@ void FinalWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
//! [1]
|
||||
*/
|
||||
drag->setMimeData(mimeData);
|
||||
drag->setPixmap(imageLabel->pixmap()->scaled(64, 64, Qt::KeepAspectRatio));
|
||||
drag->setPixmap(imageLabel->pixmap().scaled(64, 64, Qt::KeepAspectRatio));
|
||||
//! [2]
|
||||
drag->setHotSpot(QPoint(drag->pixmap().width()/2,
|
||||
drag->pixmap().height()));
|
||||
//! [2]
|
||||
|
||||
drag->start();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -124,7 +129,7 @@ void FinalWidget::mousePressEvent(QMouseEvent *event)
|
||||
dragStartPosition = event->pos();
|
||||
}
|
||||
|
||||
const QPixmap* FinalWidget::pixmap() const
|
||||
QPixmap FinalWidget::pixmap() const
|
||||
{
|
||||
return imageLabel->pixmap();
|
||||
}
|
||||
|
@ -68,7 +68,7 @@ class FinalWidget : public QFrame
|
||||
public:
|
||||
FinalWidget(QWidget *parent, const QString &name, const QSize &labelSize);
|
||||
void setPixmap(const QPixmap &pixmap);
|
||||
const QPixmap *pixmap() const;
|
||||
QPixmap pixmap() const;
|
||||
|
||||
protected:
|
||||
void mouseMoveEvent(QMouseEvent *event) override;
|
||||
|
@ -1,7 +1,13 @@
|
||||
HEADERS = finalwidget.h \
|
||||
screenwidget.h \
|
||||
viewer.h
|
||||
SOURCES = finalwidget.cpp \
|
||||
main.cpp \
|
||||
screenwidget.cpp \
|
||||
viewer.cpp
|
||||
TEMPLATE = lib
|
||||
TARGET = separations_snippets
|
||||
QT += core gui widgets
|
||||
|
||||
HEADERS = \
|
||||
finalwidget.h \
|
||||
screenwidget.h \
|
||||
viewer.h
|
||||
SOURCES = \
|
||||
finalwidget.cpp \
|
||||
main.cpp \
|
||||
screenwidget.cpp \
|
||||
viewer.cpp
|
||||
|
@ -145,7 +145,6 @@ QFrame* Viewer::createCentralWidget()
|
||||
QFrame* frame = new QFrame(this);
|
||||
grid = new QGridLayout(frame);
|
||||
grid->setSpacing(8);
|
||||
grid->setMargin(4);
|
||||
|
||||
layout()->setSizeConstraint(QLayout::SetFixedSize);
|
||||
|
||||
@ -324,7 +323,7 @@ void Viewer::saveImage()
|
||||
QString newImageFile = QFileInfo(info.absoluteDir(),
|
||||
info.baseName() + ".png").absoluteFilePath();
|
||||
|
||||
if (!finalWidget->pixmap()->save(newImageFile, "PNG"))
|
||||
if (!finalWidget->pixmap().save(newImageFile, "PNG"))
|
||||
(void) QMessageBox::warning(this, tr("Cannot save file"),
|
||||
tr("The file could not be saved."),
|
||||
QMessageBox::Cancel, QMessageBox::NoButton,
|
||||
|
@ -20,6 +20,7 @@ contains(QT_BUILD_PARTS, tests) {
|
||||
qstatustipevent \
|
||||
qtextobject \
|
||||
scribe-overview \
|
||||
separations \
|
||||
textblock-formats \
|
||||
textblock-fragments \
|
||||
textdocument-blocks \
|
||||
|
Loading…
x
Reference in New Issue
Block a user