本文整理汇总了C++中QUrl::fragment方法的典型用法代码示例。如果您正苦于以下问题:C++ QUrl::fragment方法的具体用法?C++ QUrl::fragment怎么用?C++ QUrl::fragment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QUrl
的用法示例。
在下文中一共展示了QUrl::fragment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: hoverOverUrl
/*!
* \author Anders Fernström
* \date 2006-02-10
*/
void CellDocument::hoverOverUrl( const QUrl &link )
{
QString filelink = link.path();
if( !link.fragment().isEmpty() )
filelink += QString("#") + link.fragment();
if( !filelink.isEmpty() && !link.path().isEmpty() )
{
if( filename_.isEmpty() || filename_.isEmpty() )
{
// replace '\' with '/' in the link path
filelink.replace( "\\", "/" );
QDir dir;
filelink = dir.absolutePath() + "/" + filelink;
}
else
{
// replace '\' with '/' in the link path
filelink.replace( "\\", "/" );
filelink = QFileInfo(filename_).absolutePath() + "/" + filelink;
}
}
emit hoverOverFile( filelink );
}
示例2: linkClicked
void DocumentBrowser::linkClicked(QUrl url)
{
if (url.path().isEmpty() && !url.fragment().isEmpty()) {
m_liteApp->mainWindow()->statusBar()->clearMessage();
//m_textBrowser->scrollToAnchor(url.fragment());
this->scrollToAnchor(url.fragment());
return;
}
emit requestUrl(url);
}
示例3: async
Future<void> GitCloneStep::perform(const ActionContext &ctxt)
{
return async([this, ctxt](Notifier notifier)
{
QUrl url = m_url;
url.setFragment(QString());
Git::GitRepo *repo = notifier.await(Git::GitRepo::clone(ctxt.get<InstallContextItem>().buildDir, url));
if (!url.fragment().isEmpty()) {
notifier.await(repo->checkout(url.fragment()));
}
});
}
示例4: setSource
void TextBrowserHelpViewer::setSource(const QUrl &url)
{
if (launchWithExternalApp(url))
return;
slotLoadStarted();
m_textBrowser->setSource(url);
QTimer::singleShot(0, this, [this, url]() {
if (!url.fragment().isEmpty())
m_textBrowser->scrollToAnchor(url.fragment());
if (QScrollBar *hScrollBar = m_textBrowser->horizontalScrollBar())
hScrollBar->setValue(0);
slotLoadFinished();
});
}
示例5: slotLinkChanged
void VKAuth::slotLinkChanged(QUrl url)
{
if ("/blank.html" == url.path()) {
QRegExp regexp("access_token=([^,]+)&expires_in=([^,]+)&user_id=([^,]+)");
QString str= url.fragment();
if( -1 != regexp.indexIn(str) ){
QString access_token = regexp.cap(1);
QString expires_in = regexp.cap(2);
QString user_id = regexp.cap(3);
QUrl request(QString("https://api.vk.com/method/%1.xml?").arg("friends.get"));
request.addQueryItem("user_id", user_id);
request.addQueryItem("fields", "online");
request.addQueryItem("v", "5.2");
request.addQueryItem("access_token", access_token);
QNetworkAccessManager *manager = new QNetworkAccessManager(this);
m_http = manager->get(QNetworkRequest(request));
QObject::connect(m_http, SIGNAL(finished()), this, SLOT(slotDone()));
}
}
else if("/api/login_failure.html" == url.path()){
emit unsuccess();
}
}
示例6: loginUrlChanged
void VKApi::loginUrlChanged(const QUrl& url) {
qDebug() << "login url filename: \n" << url.fileName() << "\n";
if (url.fileName() == "blank.html") {
QUrlQuery q(url.fragment());
accessToken = q.queryItemValue("access_token");
qDebug() << "got access token: " << accessToken << "\n";
QMap<QString, QString> params;
method("users.get", params, [this]( const QJsonDocument* json, QNetworkReply::NetworkError) {
loginView->close();
loginView = 0;
if (json) {
auto obj = json->object();
qDebug() << obj.keys().join(",");
user->_name = obj["first_name"].toString() + " " + obj["last_name"].toString();
user->_uid = QString::number( obj["uid"].toInt() );
} else {
this->logout();
this->login();
}
emit loginStatusChanged();
});
loginView->setVisible(false);
}
}
示例7: fragment
QString QUrlProto::fragment() const
{
QUrl *item = qscriptvalue_cast<QUrl*>(thisObject());
if (item)
return item->fragment();
return QString();
}
示例8: setUrlHtml
void DocumentBrowser::setUrlHtml(const QUrl &url,const QString &data)
{
const HistoryEntry &historyEntry = createHistoryEntry();
if (!data.isEmpty()) {
m_htmlWidget->setHtml(data,url);
}
m_url = url;
if (!url.fragment().isEmpty()) {
m_htmlWidget->scrollToAnchor(url.fragment());
} else {
m_htmlWidget->setScrollBarValue(Qt::Horizontal,0);
m_htmlWidget->setScrollBarValue(Qt::Vertical,0);
}
m_urlComboBox->blockSignals(true);
int index = m_urlComboBox->findText(m_url.toString());
if (index == -1) {
m_urlComboBox->addItem(m_url.toString());
index = m_urlComboBox->count()-1;
}
m_urlComboBox->setCurrentIndex(index);
m_urlComboBox->blockSignals(false);
if (!m_backwardStack.isEmpty() && url == m_backwardStack.top().url)
{
// restoreHistoryEntry(m_backwardStack.top());
return;
}
if (!m_backwardStack.isEmpty()) {
m_backwardStack.top() = historyEntry;
}
HistoryEntry entry;
entry.url = url;
m_backwardStack.push(entry);
emit backwardAvailable(m_backwardStack.count() > 1);
if (!m_forwardStack.isEmpty() && url == m_forwardStack.top().url) {
m_forwardStack.pop();
emit forwardAvailable(m_forwardStack.count() > 0);
} else {
m_forwardStack.clear();
emit forwardAvailable(false);
}
}
示例9: setUrl
void QtWebKitWebWidget::setUrl(const QUrl &url, bool typed)
{
if (url.scheme() == QLatin1String("javascript"))
{
evaluateJavaScript(url.path());
return;
}
if (!url.fragment().isEmpty() && url.matches(getUrl(), (QUrl::RemoveFragment | QUrl::StripTrailingSlash | QUrl::NormalizePathSegments)))
{
m_webView->page()->mainFrame()->scrollToAnchor(url.fragment());
return;
}
m_isTyped = typed;
if (url.isValid() && url.scheme().isEmpty() && !url.path().startsWith('/'))
{
QUrl httpUrl = url;
httpUrl.setScheme(QLatin1String("http"));
m_webView->setUrl(httpUrl);
}
else if (url.isValid() && (url.scheme().isEmpty() || url.scheme() == "file"))
{
QUrl localUrl = url;
localUrl.setScheme(QLatin1String("file"));
m_webView->setUrl(localUrl);
}
else
{
m_webView->setUrl(url);
}
notifyTitleChanged();
notifyIconChanged();
}
示例10: urlChanged
void LoginDialog::urlChanged(const QUrl &url)
{
qDebug() << "[LoginDialog::urlChanged]" << url.toString();
QSettings settings;
QStringList list = url.fragment().split("=");
if (list[0] == "access_token") {
settings.setValue("access_token", list[1]);
QDialog::accept();
emit loggedIn();
}
}
示例11: requestImage
QImage SvgElementProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
{
// Resolve URL
QUrl url = QUrl(id);
if (url.isRelative() && !mBaseUrl.isEmpty())
url = mBaseUrl.resolved(url);
if (!url.isValid())
return placeholder(QString("Invalid URL\nBase: %1\nInput: %2").arg(mBaseUrl.toString()).arg(id), requestedSize);
// Make a filename from the given URL
QString imagepath = QQmlFile::urlToLocalFileOrQrc(url);
// Fragment is used to specify SVG element
QString elementId = url.fragment();
// Load image
QSvgRenderer renderer;
if (!renderer.load(imagepath))
{
qWarning() << "Unable to load image:" << imagepath;
return placeholder(QStringLiteral("Unable to load image:\n") + imagepath, requestedSize);
}
// Check whether requested element exists
if (!elementId.isEmpty() && !renderer.elementExists(elementId))
return placeholder(QStringLiteral("Unable to find element:\n") + elementId + "\nin image:\n" + imagepath,
requestedSize);
// Get image or element size
QSize itemSize = elementId.isEmpty() ? renderer.defaultSize() : renderer.boundsOnElement(elementId).size().toSize();
if (size)
*size = itemSize;
// Create image
QImage image(requestedSize.width() > 0 ? requestedSize.width() : itemSize.width(),
requestedSize.height() > 0 ? requestedSize.height() : itemSize.height(),
QImage::Format_ARGB32_Premultiplied);
image.fill(Qt::transparent);
// Paint svg or element
QPainter p(&image);
if (elementId.isEmpty())
renderer.render(&p);
else
renderer.render(&p, elementId);
return image;
}
示例12: urlEncodeQueryString
QString QzTools::urlEncodeQueryString(const QUrl &url)
{
QString returnString = url.toString(QUrl::RemoveQuery | QUrl::RemoveFragment);
if (url.hasQuery()) {
returnString += QLatin1Char('?') + url.query(QUrl::FullyEncoded);
}
if (url.hasFragment()) {
returnString += QLatin1Char('#') + url.fragment(QUrl::FullyEncoded);
}
returnString.replace(QLatin1Char(' '), QLatin1String("%20"));
return returnString;
}
示例13: alink
/**
\param url
**/
void ResumCtaWidget::alink ( const QUrl &url )
{
BL_FUNC_DEBUG
QString linker = url.fragment();
///TODO: REVISAR ESTA FUNCION QUE NO HACE BIEN SU TRABAJO.
if ( linker == "ver" ) {
// TODO
} else if ( linker == "asiento" ) {
//QString ordenasiento = l.right(l.length() - 2);
//( ( BcCompany * ) mainCompany() ) ->intapuntsempresa();
} else {
BcAsientoView *view = g_asiento;
bool ok;
view->muestraAsiento ( linker.toInt ( &ok ) );
} // endif
}
示例14: setSource
void QtWebKitHelpViewer::setSource(const QUrl &url)
{
QUrl oldWithoutFragment = source();
oldWithoutFragment.setFragment(QString());
m_webView->load(url);
// if the new url only changes the anchor,
// then webkit does not send loadStarted nor loadFinished,
// so we should do that manually in that case
QUrl newWithoutFragment = url;
newWithoutFragment.setFragment(QString());
if (oldWithoutFragment == newWithoutFragment) {
m_webView->page()->mainFrame()->scrollToAnchor(url.fragment());
slotLoadStarted();
slotLoadFinished();
}
}
示例15: textBrowser_anchorClicked
void WizardDialog::textBrowser_anchorClicked(const QUrl & url)
{
QString name = url.fragment();
// std::cout << name.toUtf8().data() << std::endl;
CopasiUI3Window * pMainWindow = dynamic_cast<CopasiUI3Window *>(copasiMainWindow);
if (name == "Model Settings")
{
if (pMainWindow)
pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Model, std::string());
}
else if (name == "Reaction Overview")
{
if (pMainWindow)
pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Reactions, std::string());
}
else if (name == "Report Definition")
{
if (pMainWindow)
pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::ReportTemplates, std::string());
}
else if (name == "Step 1")
{
buttonGroup->button(0)->setChecked(true);
buttonGroup2_clicked(this->buttonGroup->checkedId());
}
else if (name == "Time Course")
{
if (pMainWindow)
pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::TimeCourse, std::string());
}
else if (name == "Plot Definition Overview")
{
if (pMainWindow)
pMainWindow->getMainWidget()->switchToOtherWidget(ListViews::WidgetType::Plots, std::string());
}
else
{
CQMessageBox::information(this, "Error", "Link not found",
QMessageBox::Ok, QMessageBox::Ok);
}
}