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


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

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


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

示例1: showEvent

/** Show Event:
 * When the dialog is shown, try to extract a URL from the clipboard
 * and paste it in the Edit box.
 * showEvent can happen not only on exec() but I think it's cool to
 * actualize the URL on showEvent (eg. change virtual desktop...)
 **/
void OpenUrlDialog::showEvent( QShowEvent *ev )
{
    (void) ev;
    bShouldEnqueue = false;
    edit->setFocus( Qt::OtherFocusReason );
    if( !lastUrl.isEmpty() && edit->text().isEmpty() )
    {
        /* The text should not have been changed, excepted if the user
        has clicked Cancel before */
        edit->setText( lastUrl );
    }
    else
        edit->clear();

    if( bClipboard )
    {
        QClipboard *clipboard = QApplication::clipboard();
        assert( clipboard != NULL );
        QString txt = clipboard->text( QClipboard::Selection ).trimmed();

        if( txt.isEmpty() || ( !txt.contains("://") && !QFile::exists(txt) ) )
            txt = clipboard->text( QClipboard::Clipboard ).trimmed();

        if( txt.contains( "://" ) || QFile::exists( txt ) )
            edit->setText( txt );
    }
}
开发者ID:BloodExecutioner,项目名称:vlc,代码行数:33,代码来源:openurl.cpp

示例2: lalloc

/**
 * Get selection from clipboard
 *
 */
void
clip_mch_request_selection(VimClipboard *cbd)
{
	QClipboard *clip = QApplication::clipboard();
	if ( clip->text((QClipboard::Mode)cbd->clipboardMode).size() == 0 ) {
		return;
	}

	QByteArray text = VimWrapper::convertTo(clip->text( (QClipboard::Mode)cbd->clipboardMode));

	if ( text.isEmpty() ) {
		// This should not happen, but if it does vim
		// behaves badly so lets be extra carefull
		return;
	}

	char_u	*buffer;
	buffer = lalloc( text.size(), TRUE);
	if (buffer == NULL)
		return;

	for (int i = 0; i < text.size(); ++i) {
		buffer[i] = text[i];
	}

	clip_yank_selection(MAUTO, buffer, text.size(), cbd);
	vim_free(buffer);
}
开发者ID:wfyaibaib,项目名称:vim-qt,代码行数:32,代码来源:gui_qt.cpp

示例3: wzGetSelection

QString wzGetSelection()
{
	QString aText;
	QClipboard *clipboard = QApplication::clipboard();
	aText = clipboard->text(QClipboard::Selection);                           // try X11 specific buffer first
	if (aText.isEmpty()) aText = clipboard->text(QClipboard::Clipboard);      // if not, try generic clipboard
	return aText;
}
开发者ID:Mysteryem,项目名称:warzone2100,代码行数:8,代码来源:wzapp_qt.cpp

示例4: clipHackTimeout

// The hack for Windows: periodically check for clipboard changes
void ImodClipboard::clipHackTimeout()
{
  QClipboard *cb = QApplication::clipboard();
  //cb->setSelectionMode(false);
  if (cb->text() == mSavedClipboard)
    return;
  mSavedClipboard = cb->text();
  clipboardChanged();
}
开发者ID:LabShare,项目名称:IMOD,代码行数:10,代码来源:client_message.cpp

示例5: main

int main(int argc, char **argv)
{
    QApplication app(argc, argv);
    QClipboard *board = QApplication::clipboard();
#ifdef Q_OS_WINCE
    return (board->text() == QLatin1String("testString.!")) ? 0 : 1;
#else
    return (board->text() == app.arguments().at(1)) ? 0 : 1;
#endif
}
开发者ID:KDE,项目名称:android-qt,代码行数:10,代码来源:main.cpp

示例6: clipboardChanged

// The clipboard changed - check for window ID and OK or ERROR
// NOTE: on Windows, Qt 3 needed to exit with ::exit instead of
// QApplication::exit,  otherwise it would hang for a long time or until the 
// timeout occurred.  It complains in Qt 4 about deleting an object during its
// event handler, but qapp::exit seems fine now.
void ImodSendEvent::clipboardChanged()
{
  QClipboard *cb = QApplication::clipboard();
  //cb->setSelectionMode(false);
  QString text = cb->text();
  if (debugOut)
    fprintf(stderr, "Imodsendevent - clipboard = %s\n", LATIN1(text));

  // Ignore if empty text, no spaces, starting space, or wrong ID
  if (text.isEmpty())
    return;
  int index = text.indexOf(" ");
  if (index <= 0)
    return;
  if ((text.left(index)).toInt() != winID) 
    return;

  // If OK, just exit; if ERROR, give message and exit with error status
  if (text.mid(index + 1) == "OK") {
    QApplication::exit(0);
    return;
  }
  if (text.mid(index + 1) != "ERROR")
    return;
  fprintf(stderr, "ERROR: imodsendevent - message received but error occurred "
          "executing it\n");
  QApplication::exit(3);
}
开发者ID:LabShare,项目名称:IMOD,代码行数:33,代码来源:imodsendevent.cpp

示例7: copySelectedDirectories

void VDirectoryTree::copySelectedDirectories(bool p_isCut)
{
    QList<QTreeWidgetItem *> items = selectedItems();
    if (items.isEmpty()) {
        return;
    }

    QJsonArray dirs;
    for (int i = 0; i < items.size(); ++i) {
        VDirectory *dir = getVDirectory(items[i]);
        dirs.append(dir->fetchPath());
    }

    QJsonObject clip;
    clip[ClipboardConfig::c_magic] = getNewMagic();
    clip[ClipboardConfig::c_type] = (int)ClipboardOpType::CopyDir;
    clip[ClipboardConfig::c_isCut] = p_isCut;
    clip[ClipboardConfig::c_dirs] = dirs;

    QClipboard *clipboard = QApplication::clipboard();
    clipboard->setText(QJsonDocument(clip).toJson(QJsonDocument::Compact));

    qDebug() << "copied directories info" << clipboard->text();

    int cnt = dirs.size();
    g_mainWin->showStatusMessage(tr("%1 %2 %3")
                                   .arg(cnt)
                                   .arg(cnt > 1 ? tr("folders") : tr("folder"))
                                   .arg(p_isCut ? tr("cut") : tr("copied")));
}
开发者ID:vscanf,项目名称:vnote,代码行数:30,代码来源:vdirectorytree.cpp

示例8: replaceClipboardVariable

void SnippetCompleter::replaceClipboardVariable(QString &snippetContent)
{
    if (snippetContent.contains("%clipboard")) {
        QClipboard *clipboard = QApplication::clipboard();
        snippetContent.replace("%clipboard", clipboard->text());
    }
}
开发者ID:Bloodknight,项目名称:CuteMarkEd,代码行数:7,代码来源:snippetcompleter.cpp

示例9: on_actionPaste_FEN_triggered

void MainWindow::on_actionPaste_FEN_triggered() {
    if (!view->ready)
        return;

    QClipboard *clipboard = QApplication::clipboard();
    std::string originalText = clipboard->text().toUtf8().constData();

    cBoard boardCopy = view->gameManager.board;

    if (!(view->gameManager.board.setBoard(originalText))) {
        QMessageBox msgBox;
        msgBox.setText("Invalid FEN");
        msgBox.setIcon(QMessageBox::Warning);
        msgBox.setStandardButtons(QMessageBox::Ok);
        msgBox.setDefaultButton(QMessageBox::Ok);
        msgBox.exec();

        view->gameManager.board = boardCopy;
    }
    else {
        view->display->updateSelected(-1);
        view->display->updateFromToIndicators(-1,-1);
        view->gameManager.moveHistory.clear();
    }

    view->display->setPos(view->gameManager.board.currentPos);
    updateToPlayLabel();

    if (view->checkGameState())
        return;
}
开发者ID:Andrew-D-Gibson,项目名称:Shallow-Cyan,代码行数:31,代码来源:mainwindow.cpp

示例10: paste

void Plot::paste()
{
    QLocale l;
    QClipboard *clipboard = QApplication::clipboard();
    QString text = clipboard->text();

    if(!text.isEmpty()) {
        QList<QString> items = text.split('\n');
        QList<float> values;
        for(int i = 0; i < items.count(); i++) {
            values.append(l.toFloat(items[i]));
        }


        this->detachItems();

        // Insert new curves
        curve = new QwtPlotCurve( "y = sin(x)" );
        curve->setRenderHint( QwtPlotItem::RenderAntialiased );
        curve->setLegendAttribute( QwtPlotCurve::LegendShowLine, true );
        curve->setPen( Qt::red );
        curve->attach( this );

        Data* data = new Data(&values);
        curve->setData(data);

        setAxisScale( yLeft, data->yMin, data->yMax);
        setAxisScale( xBottom, data->xMin, data->xMax);


        QwtPlotGrid* grid = new QwtPlotGrid();
        grid->setPen(Qt::black, 0.1, Qt::DashLine);
        grid->attach(this);
    }
}
开发者ID:volthouse,项目名称:desktop,代码行数:35,代码来源:plot.cpp

示例11: onHasMsg

/**
 * Checks if the action \a pMsg is available. This is for enabling/disabling
 * the corresponding buttons or menu items for this action.
 */
bool EditorView::onHasMsg(const char* pMsg) const
{
    if (strcmp(pMsg,"Run")==0)  return true;
    if (strcmp(pMsg,"DebugStart")==0)  return true;
    if (strcmp(pMsg,"DebugStop")==0)  return true;
    if (strcmp(pMsg,"SaveAs")==0)  return true;
    if (strcmp(pMsg,"Print")==0) return true;
    if (strcmp(pMsg,"PrintPreview")==0) return true;
    if (strcmp(pMsg,"PrintPdf")==0) return true;
    if (strcmp(pMsg,"Save")==0) { 
        return d->textEdit->document()->isModified();
    } else if (strcmp(pMsg,"Cut")==0) {
        bool canWrite = !d->textEdit->isReadOnly();
        return (canWrite && (d->textEdit->textCursor().hasSelection()));
    } else if (strcmp(pMsg,"Copy")==0) {
        return ( d->textEdit->textCursor().hasSelection() );
    } else if (strcmp(pMsg,"Paste")==0) {
        QClipboard *cb = QApplication::clipboard();
        QString text;

        // Copy text from the clipboard (paste)
        text = cb->text();

        bool canWrite = !d->textEdit->isReadOnly();
        return ( !text.isEmpty() && canWrite );
    } else if (strcmp(pMsg,"Undo")==0) {
        return d->textEdit->document()->isUndoAvailable ();
    } else if (strcmp(pMsg,"Redo")==0) {
        return d->textEdit->document()->isRedoAvailable ();
    }

    return false;
}
开发者ID:5263,项目名称:FreeCAD,代码行数:37,代码来源:EditorView.cpp

示例12: tick_clipboard

void ItemList::tick_clipboard()
{
    PasspotPlugin *plugin = dynamic_cast<PasspotPlugin*>(get_plugin().pointer());
    assert(NULL != plugin);
    QClipboard *board = QApplication::clipboard();
    assert(NULL != board);

    const bool clipboard_changed = (_clipboard_hash != hash(board->text()));
    --_clipboard_countdown;
    if (!clipboard_changed && _clipboard_countdown > 0)
    {
        QString msg = _clipboard_status + QString(tr(" %1秒")).arg(_clipboard_countdown);
        plugin->show_status(msg, _clipboard_countdown * 1000);
        return;
    }

    if (clipboard_changed)
    {
        plugin->show_status(tr("剪贴板已经被覆盖"), 5000);
    }
    else
    {
        board->setText(QString());
        plugin->show_status(tr("剪贴板已经被清空"), 5000);
    }
    _clipboard_hash = 0;
    _clipboard_countdown = 0;
    _clipboard_status.clear();
    if (NULL != _clipboard_timer)
        _clipboard_timer->stop();
}
开发者ID:jingqi,项目名称:organic,代码行数:31,代码来源:item_list.cpp

示例13: PasteFromClipboard

void MyLineEdit::PasteFromClipboard()
{
	QClipboard *clipboard = QApplication::clipboard();
	QString text = clipboard->text();

	if (parameterContainer)
	{
		QString type = GetType(objectName());
		if (type == QString("vect3") || type == QString("logvect3"))
		{
			QStringList numbersStr = text.split(' ');
			if (numbersStr.length() == 3)
			{
				QString nameVect = parameterName.left(parameterName.length() - 2);
				QString lineEditNameX, lineEditNameY, lineEditNameZ;
				if (type == QString("vect3"))
				{
					lineEditNameX = QString("vect3_%1_x").arg(nameVect);
					lineEditNameY = QString("vect3_%1_y").arg(nameVect);
					lineEditNameZ = QString("vect3_%1_z").arg(nameVect);
				}
				else if (type == QString("logvect3"))
				{
					lineEditNameX = QString("logvect3_%1_x").arg(nameVect);
					lineEditNameY = QString("logvect3_%1_y").arg(nameVect);
					lineEditNameZ = QString("logvect3_%1_z").arg(nameVect);
				}
				MyLineEdit *lineEditX = parent()->findChild<MyLineEdit *>(lineEditNameX);
				MyLineEdit *lineEditY = parent()->findChild<MyLineEdit *>(lineEditNameY);
				MyLineEdit *lineEditZ = parent()->findChild<MyLineEdit *>(lineEditNameZ);
				if (lineEditX) lineEditX->setText(numbersStr[0]);
				if (lineEditY) lineEditY->setText(numbersStr[1]);
				if (lineEditZ) lineEditZ->setText(numbersStr[2]);
			}
			emit editingFinished();
		}

		if (type == QString("vect4"))
		{
			QStringList numbersStr = text.split(' ');
			if (numbersStr.length() == 4)
			{
				QString nameVect = parameterName.left(parameterName.length() - 2);
				QString lineEditNameX = QString("vect4_%1_x").arg(nameVect);
				QString lineEditNameY = QString("vect4_%1_y").arg(nameVect);
				QString lineEditNameZ = QString("vect4_%1_z").arg(nameVect);
				QString lineEditNameW = QString("vect4_%1_w").arg(nameVect);
				MyLineEdit *lineEditX = parent()->findChild<MyLineEdit *>(lineEditNameX);
				MyLineEdit *lineEditY = parent()->findChild<MyLineEdit *>(lineEditNameY);
				MyLineEdit *lineEditZ = parent()->findChild<MyLineEdit *>(lineEditNameZ);
				MyLineEdit *lineEditW = parent()->findChild<MyLineEdit *>(lineEditNameW);
				if (lineEditX) lineEditX->setText(numbersStr[0]);
				if (lineEditY) lineEditY->setText(numbersStr[1]);
				if (lineEditZ) lineEditZ->setText(numbersStr[2]);
				if (lineEditW) lineEditW->setText(numbersStr[3]);
			}
			emit editingFinished();
		}
	}
}
开发者ID:mancoast,项目名称:mandelbulber2,代码行数:60,代码来源:my_line_edit.cpp

示例14: eventFilter

bool RKConsole::eventFilter (QObject *, QEvent *e) {
	if (e->type () == QEvent::KeyPress) {
		QKeyEvent *k = (QKeyEvent *)e;
		return handleKeyPress (k);
	} else if (e->type () == QEvent::MouseButtonPress){
		QMouseEvent *m = (QMouseEvent *)e;
		if (m->button() == Qt::RightButton) {
			doPopupMenu (m->globalPos ());
			return (true);
		}
		return (false);
	} else if (e->type () == QEvent::MouseButtonRelease){
		QMouseEvent *m = (QMouseEvent *)e;
		if (m->button() == Qt::MidButton) {
			QClipboard *cb = QApplication::clipboard ();
			submitBatch (cb->text (QClipboard::Selection));
			return (true);
		} /* else if (m->button () == Qt::LeftButton) {
			// prevent cursor from leaving last line
			uint para=0; uint p=0;
			view->cursorPosition (&para, &p);
			if (para != doc->numLines () - 1) {
				int y = view->y ();
				view->setCursorPosition (doc->numLines() -1, p);
				int y2 = view->y ();
				qDebug ("%d, %d", y, y2);
				view->scroll (0, y - y2);
			}
		} */ // not good, yet: always jumps to bottom of view
		return (false);
	} else {
		return false;
	}
}
开发者ID:svn2github,项目名称:rkward-svn-mirror,代码行数:34,代码来源:rkconsole.cpp

示例15: paste_word

void Main::paste_word() {
	QClipboard *clip = QApplication::clipboard();

	QString text = clip->text();

	ui.paraula->setText(text);
	treballaBuscar();
}
开发者ID:cpina,项目名称:qdacco,代码行数:8,代码来源:main.cpp


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