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


C++ QClipboard::image方法代码示例

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


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

示例1: on_editorCommandPaste_triggered

void CWizDocumentWebViewPage::on_editorCommandPaste_triggered()
{
    QClipboard* clip = QApplication::clipboard();
    Q_ASSERT(clip);

    //const QMimeData* mime = clip->mimeData();
    //qDebug() << mime->formats();
    //qDebug() << mime->data("text/html");
    //qDebug() << mime->hasImage();

    if (!clip->image().isNull()) {
        // save clipboard image to $TMPDIR
        QString strTempPath = Utils::PathResolve::tempPath();
        CString strFileName = strTempPath + WizIntToStr(GetTickCount()) + ".png";
        if (!clip->image().save(strFileName)) {
            TOLOG("ERROR: Can't save clipboard image to file");
            return;
        }

        QMimeData* data = new QMimeData();
        QString strHtml = getImageHtmlLabelByFile(strFileName);
        data->setHtml(strHtml);
        clip->setMimeData(data);
    }
}
开发者ID:edagarli,项目名称:WizQTClient,代码行数:25,代码来源:wizDocumentWebView.cpp

示例2: on_editorCommandPaste_triggered

void CWizDocumentWebViewPage::on_editorCommandPaste_triggered()
{
    QClipboard* clip = QApplication::clipboard();
    Q_ASSERT(clip);

    const QMimeData* mime = clip->mimeData();
//    QStringList formats = mime->formats();
//    for(int i = 0; i < formats.size(); ++ i) {
//        qDebug() << "Mime Format: " << formats.at(i) << " Mime data: " << mime->data(formats.at(i));
//    }

    if (mime->hasHtml())
    {
        QString strHtml = mime->html();
        QRegExp regHead("</?head[^>]*>", Qt::CaseInsensitive);
        if (strHtml.contains(regHead))
        {
            // convert mass html to rtf, then convert rft to html
            QTextDocument textParase;
            textParase.setHtml(strHtml);
            strHtml = textParase.toHtml();

            QRegExp regBodyContant("<body[^>]*>[\\s\\S]*</body>");
            int index = regBodyContant.indexIn(strHtml);
            if (index > -1)
            {
                QString strBody = regBodyContant.cap(0);
                if (strBody.isEmpty())
                    return;

                QRegExp regBody = QRegExp("</?body[^>]*>", Qt::CaseInsensitive);
                strBody.replace(regBody, "");
                strHtml = strBody;

                QMimeData* data = new QMimeData();
                data->setHtml(strHtml);
                clip->setMimeData(data);
                return;
            }
        }
    }

    if (!clip->image().isNull()) {
        // save clipboard image to $TMPDIR
        QString strTempPath = Utils::PathResolve::tempPath();
        CString strFileName = strTempPath + WizIntToStr(GetTickCount()) + ".png";
        if (!clip->image().save(strFileName)) {
            TOLOG("ERROR: Can't save clipboard image to file");
            return;
        }

        QMimeData* data = new QMimeData();
        QString strHtml = getImageHtmlLabelByFile(strFileName);
        data->setHtml(strHtml);
        clip->setMimeData(data);
    }
}
开发者ID:guanxiaochao,项目名称:WizQTClient,代码行数:57,代码来源:wizDocumentWebView.cpp

示例3: PasteFromClipboard

void SliceEditView::PasteFromClipboard()
{
	if(supportMode)
		return;

	QClipboard *clipboard = QApplication::clipboard();
	if(clipboard->image().isNull())
		return;

	modified = true;
	topImg = clipboard->image();
	pDrawingContext->SetUpperImg(&topImg);
	RefreshContext(1);//so we can undo the paste...
	SaveToUndoBuffer();//since the image is altered, save to the buffer.
	ReCompress();
}
开发者ID:denisoft,项目名称:B9Creator,代码行数:16,代码来源:SliceEditView.cpp

示例4: paste

void VoxelEditor::paste()
{
    deselect();

    // test for image in clipboard
    QClipboard * clipboard = QApplication::clipboard();
    QImage img = clipboard->image();
    if (img.isNull()) {
        // paste whatever we have in the internal copied list
        selected_list = copied_list;
    } else {
        // paste image from clipboard
        selected_list.clear();
        SelectedVoxel voxel;
        for (int x = 0; x < img.width(); x++)
        for (int y = 0; y < img.height(); y++) {
            QColor pixel = QColor(img.pixel(x, y));
            if (pixel.alpha() <= 0)
                continue;
            RGBColor c(pixel.red(), pixel.green(), pixel.blue());
            unsigned char cc = VoxelFile::get_closest_index(c);
            voxel.x = x;
            voxel.y = 0;
            voxel.z = img.height() - y;
            voxel.v = cc;
            selected_list.push_back(voxel);
        }
    }
    window->set_status("Pasted voxels");
    on_changed();
}
开发者ID:Dakror,项目名称:voxie,代码行数:31,代码来源:voxeditor.cpp

示例5: PasteFromClipboard

void SliceEditView::PasteFromClipboard()
{
	if(supportMode)
		return;

	QClipboard *clipboard = QApplication::clipboard();
	if(clipboard->image().isNull())
		return;

	modified = true;
	topImg = clipboard->image();
	pDrawingContext->SetUpperImg(&topImg);
    RefreshContext(1);//所以我们可以撤消粘贴...
    SaveToUndoBuffer();//由于图像被改变,保存到缓冲器。
	ReCompress();
}
开发者ID:SHINOTECH,项目名称:B9Creator-QT5.X,代码行数:16,代码来源:SliceEditView.cpp

示例6: paste

void CopyPaste::paste() {
	QPoint point = QPoint::QPoint(0,0);
	QImage *image = ourImage->getImage();
	QPainter painter(image);
	QClipboard *clipboard = QApplication::clipboard();
	QImage paste = clipboard->image();
	painter.drawImage(point, paste);
	ourImage->update();
}
开发者ID:adam-davis,项目名称:CS-Capstone,代码行数:9,代码来源:CopyPaste.cpp

示例7: return

// ---------------------------------------------------------------------
void *wdclipreadimage(char * s)
{
  QClipboard *clipboard = app->clipboard();
  if (!clipboard) return 0;
  if (!strlen(s)) return 0;
  QImage image = clipboard->image();
  if (!image.isNull()) {
    return (image.save(s))?(char *)-1:0;
  }
  return 0;
}
开发者ID:0branch,项目名称:qtide,代码行数:12,代码来源:clipboard.cpp

示例8: image

	QScriptValue Clipboard::image() const
	{
		QClipboard *clipboard = QApplication::clipboard();

        return Image::constructor(clipboard->image(mMode), engine());
    }
开发者ID:sakazuki,项目名称:actiona,代码行数:6,代码来源:clipboard.cpp

示例9: if

ImageArea::ImageArea(const bool &isOpen, const QString &filePath, QWidget *parent) :
    QWidget(parent), mIsEdited(false), mIsPaint(false), mIsResize(false)
{
    setMouseTracking(true);

    mRightButtonPressed = false;
    mFilePath = QString();
    mOpenFilter = "Windows Bitmap(*.bmp)";
    mSaveFilter = "Windows Bitmap(*.bmp)";
    initializeImage();
    mZoomFactor = 1;

    mAdditionalTools = new AdditionalTools(this, this->parent());

    if(isOpen && filePath.isEmpty())
    {
        open();
    }
    else if(isOpen && !filePath.isEmpty())
    {
        open(filePath);
    }
    else
    {
        int width, height;
        width = Data::Instance()->getBaseSize().width();
        height = Data::Instance()->getBaseSize().height();
        if (Data::Instance()->getIsInitialized() &&
            Data::Instance()->getIsAskCanvasSize())
        {
            QClipboard *globalClipboard = QApplication::clipboard();
            QImage mClipboardImage = globalClipboard->image();
            if (!mClipboardImage.isNull())
            {
                width = mClipboardImage.width();
                height = mClipboardImage.height();
            }
            mAdditionalTools->resizeCanvas(width, height);
            mIsEdited = false;
        }
        QPainter *painter = new QPainter(mImage);
        painter->fillRect(0, 0, width, height, Qt::white);
        painter->end();

        resize(mImage->rect().right() + 6,
               mImage->rect().bottom() + 6);
        mFilePath = QString("");
    }

    SelectionInstrument *selectionInstrument = new SelectionInstrument(this);
    connect(selectionInstrument, SIGNAL(sendEnableCopyCutActions(bool)), this, SIGNAL(sendEnableCopyCutActions(bool)));
    connect(selectionInstrument, SIGNAL(sendEnableSelectionInstrument(bool)), this, SIGNAL(sendEnableSelectionInstrument(bool)));

    mInstrumentsHandlers.fill(0, (int)INSTRUMENTS_COUNT);
    mInstrumentsHandlers[CURSOR] = selectionInstrument;
    mInstrumentsHandlers[PEN] = new PencilInstrument(this);
    mInstrumentsHandlers[LINE] = new LineInstrument(this);
    mInstrumentsHandlers[ERASER] = new EraserInstrument(this);
    mInstrumentsHandlers[RECTANGLE] = new RectangleInstrument(this);
    mInstrumentsHandlers[ELLIPSE] = new EllipseInstrument(this);
    mInstrumentsHandlers[FILL] = new FillInstrument(this);
    mInstrumentsHandlers[CURVELINE] = new CurveLineInstrument(this);
}
开发者ID:13vv2,项目名称:praktika,代码行数:63,代码来源:imagearea.cpp

示例10: onClipboardUpdated

void Widget::onClipboardUpdated()
{
    QClipboard *clip = qApp->clipboard();

    if (clip->mimeData()->hasImage()) {
        QImage image = clip->image();
        QSize origSize = image.size();
        const int minWidth = minimumWidth() - 20;
        const int minHeight = minimumHeight() - 20;
        if (image.width() <= image.height() && image.height() < minimumHeight() - 20) {
            image = image.scaledToHeight(minHeight);
        } else if (image.width() < minWidth) {
            image = image.scaledToWidth(minWidth);
        }
        if (image.width() > maximumWidth() - 10) {
            image = image.scaledToWidth(maximumWidth() - 10);
        }
        if (image.height() > maximumHeight() - 10) {
            image = image.scaledToHeight(maximumHeight() - 10);
        }

        {
            QPainter p(&image);
            QFont font;
            font.setPixelSize(15);
            p.setFont(font);
            QFontMetrics metrics(font);
            QString text = QString::number(origSize.width()) + "x" + QString::number(origSize.height());
            QRect rect = metrics.boundingRect(text).marginsAdded(QMargins(5, 5, 5, 5));
            rect.moveTopLeft(QPoint(0, 0));
            p.fillRect(rect, QColor(0, 0, 0, 128));
            p.setPen(Qt::white);
            p.drawText(rect, Qt::AlignCenter, text);
        }

        m_label->setPixmap(QPixmap::fromImage(image));
        resize(image.size());
        updateGeometry();
        m_hasTrimmed = false;
        return;
    }

    QString text = clip->text();

    const QStringList formats = clip->mimeData()->formats();
    bool onlyTextPlain = formats.contains("text/plain");
    if (onlyTextPlain) {
        for (const QString &format : formats) {
            // "Special" fake mimetypes to indicate multiselections etc.
            if (!format.contains('/') || format.toUpper() == format) {
                continue;
            }
            if (format == "text/plain" || format == "text/html") {
                continue;
            }
            onlyTextPlain = false;
            break;
        }

        QString trimmed = text.trimmed();

        if (onlyTextPlain && trimmed != text && !m_hasTrimmed) {
            clip->setText(trimmed);
            m_hasTrimmed = true;
            return;
        }
    }

    m_hasTrimmed = false;

    QFontMetrics metrics(font());

    QString filteredText;
    for (const QChar &c : text) {
        if ((c.isPrint() || c == '\n' || c == '\t') && (c.script() == QChar::Script_Latin || c.script() == QChar::Script_Common)) {
            filteredText += c;
            continue;
        }

        qDebug() << c << c.script() << c.category();

        filteredText += "0x" + QString::number(c.unicode(), 16);
    }
    text = filteredText;

    QRect boundingRect = QRect(0, 0, maximumWidth(), maximumHeight());
    boundingRect = metrics.boundingRect(boundingRect, Qt::TextWordWrap, text);
    boundingRect = boundingRect.marginsAdded(QMargins(20, 20, 20, 20));

    if (boundingRect.height() > maximumHeight()) {
        m_label->setWordWrap(false);

        QString newText;
        int h = metrics.height() * 2;
        for (const QString &line : text.split('\n')) {
            newText.append(metrics.elidedText(line, Qt::ElideRight, m_label->width() - 20) + '\n');
            h += metrics.height();
        }
        text = newText;
        boundingRect.setHeight(h);
//.........这里部分代码省略.........
开发者ID:sandsmark,项目名称:pastenotifier,代码行数:101,代码来源:widget.cpp


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