本文整理汇总了C++中QUrl函数的典型用法代码示例。如果您正苦于以下问题:C++ QUrl函数的具体用法?C++ QUrl怎么用?C++ QUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QUrl函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: QUrl
void
MainWindow::openSubIssue(void)
{
QDesktopServices::openUrl(
QUrl("https://github.com/rtxi/rtxi/issues", QUrl::TolerantMode));
}
开发者ID:anselg,项目名称:rtxi,代码行数:6,代码来源:main_window.cpp
示例2: setLoginUrl
void LoginDialog::setLoginUrl(const QString& url)
{
//ui->webView->setUrl(QUrl(""));
ui->webView->setUrl(QUrl(url));
}
开发者ID:robol,项目名称:time-tracker,代码行数:5,代码来源:logindialog.cpp
示例3: QUrl
QUrl PasswordsContentsWidget::getUrl() const
{
return QUrl(QLatin1String("about:passwords"));
}
开发者ID:OtterBrowser,项目名称:otter-browser,代码行数:4,代码来源:PasswordsContentsWidget.cpp
示例4: displaySelectedChapter
void QucsHelp::displaySelectedChapter(const QItemSelection & is)
{
const QModelIndex index = is.indexes()[0];
if(index.isValid())
textBrowser->setSource(QUrl(QucsHelpDir.filePath(links[index.row()])));
}
开发者ID:damiansimanuk,项目名称:qucs-qt4,代码行数:6,代码来源:qucshelp.cpp
示例5: resolveUrl
inline QUrl resolveUrl(const QString &url) const
{ return resolveUrl(QUrl(url)); }
开发者ID:3163504123,项目名称:phantomjs,代码行数:2,代码来源:qtextbrowser.cpp
示例6: on_pushButtonOk_clicked
void DialogPreferences::on_pushButtonOk_clicked()
{
bool changed = false;
bool urlChanged = false;
quint8 number;
QString string;
string = _ui->lineEditHostlistUrl->text();
if(!QUrl(string).isValid())
{
QMessageBox::critical(NULL, trUtf8("Error"), trUtf8("You have entered an invalid URL."));
return;
}
number = _ui->comboBoxTestMode->currentIndex();
switch(number)
{
case 0:
number = TestMode::Info;
break;
case 1:
number = TestMode::Ping;
break;
case 2:
number = TestMode::Download;
break;
case 3:
number = TestMode::All;
break;
default:
number = TestMode::All;
}
if(number != TESTMODE)
{
changed = true;
TESTMODE = (TestMode::Mode) number;
}
number = _ui->spinBoxPingsPerHost->value();
if(number != PINGSPERHOST)
{
changed = true;
PINGSPERHOST = number;
}
number = _ui->spinBoxPingThreads->value();
if(number != PINGTHREADS)
{
changed = true;
PINGTHREADS = number;
}
number = _ui->spinBoxPingTimeout->value();
if(number != PINGTIMEOUTSECS)
{
changed = true;
PINGTIMEOUTSECS = number;
}
number = _ui->spinBoxDownloadTestSecs->value();
if(number != DOWNLOADTESTSECS)
{
changed = true;
DOWNLOADTESTSECS = number;
}
if(string != HOSTLISTURL)
{
changed = true;
urlChanged = true;
HOSTLISTURL = string;
}
if(changed)
{
emit savePreferences();
}
if(urlChanged)
{
emit hostlistUrlChanged();
}
close();
}
开发者ID:AlexGidarakos,项目名称:QSpeedTest,代码行数:93,代码来源:dialogpreferences.cpp
示例7: QNetworkRequest
//загрузка файла
void guBookUploader::uploadEbookData(ebook uploadEbook)
{
QString uploadedMd5 = uploadEbook.MD5;
//test
serviceUrl = "http://localhost/lgws/service.php";
QNetworkRequest *uploadEbookRequest;
//TODO: вести лог
uploadEbookRequest = new QNetworkRequest(QUrl(serviceUrl));
QByteArray fileToSend; // byte array to be sent in POST
if(!uploadEbook.inLib)
{
QFile uploadFile(uploadEbook.filePath);
if (!uploadFile.open(QIODevice::ReadOnly))
{
//TODO: дать сигнал о том, что закачка провалилась так как не удалось открыть файл
return;
}
fileToSend = uploadFile.readAll();
uploadFile.close(); //расскомментировать
}
////////////////////начало кода, взятого из "formpost"
QString encodingS;
encodingS = "utf-8";
QString userAgentS;
QString refererS;
QStringList fieldNames;
QStringList fieldValues;
QStringList fileFieldNames;
QStringList fileNames;
QStringList fileMimes;
QList<QByteArray> files;
fieldNames << "xml";
fieldValues << sendEbookInfoXML(uploadEbook);
if(!uploadEbook.inLib)
{
fieldNames << "MAX_FILE_SIZE";
fieldValues << QString::number(maxUploadFileSize);
fileFieldNames << "uploadedfile";
fileNames << uploadEbook.fileName +"."+ uploadEbook.fileExtension;
fileMimes << "application/octet-stream";
files << fileToSend;
}
QString crlf="\r\n";
qsrand(QDateTime::currentDateTime().toTime_t());
QString b=QVariant(qrand()).toString()+QVariant(qrand()).toString()+QVariant(qrand()).toString();
QString boundary="---------------------------"+b;
QString endBoundary=crlf+"--"+boundary+"--"+crlf;
QString contentType="multipart/form-data; boundary="+boundary;
boundary="--"+boundary+crlf;
QByteArray bond=boundary.toAscii();
QByteArray send;
bool first=true;
for (int i=0; i<fieldNames.size(); i++) {
send.append(bond);
if (first) {
boundary=crlf+boundary;
bond=boundary.toAscii();
first=false;
}
send.append(QString("Content-Disposition: form-data; name=\""+fieldNames.at(i)+"\""+crlf).toAscii());
if (encodingS=="utf-8") send.append(QString("Content-Transfer-Encoding: 8bit"+crlf).toAscii());
send.append(crlf.toAscii());
send.append(strToEnc(fieldValues.at(i),encodingS));
}
for (int i=0; i<files.size(); i++) {
send.append(bond);
send.append(QString("Content-Disposition: form-data; name=\""+fileFieldNames.at(i)+"\"; filename=\""+fileNames.at(i)+"\""+crlf).toAscii());
send.append(QString("Content-Type: "+fileMimes.at(i)+crlf+crlf).toAscii());
send.append(files.at(i));
}
send.append(endBoundary.toAscii());
uploadEbookRequest->setHeader(QNetworkRequest::ContentLengthHeader, QVariant(send.size()).toString());
uploadEbookRequest->setHeader(QNetworkRequest::ContentTypeHeader, contentType.toAscii());
uploadEbookRequest->setRawHeader("Accept","text/html,text/xml,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
uploadEbookRequest->setRawHeader("Accept-Charset","windows-1251,utf-8;q=0.7,*;q=0.7");
uploadEbookRequest->setRawHeader("Accept-Encoding", "gzip,deflate");//,qcompress
uploadEbookRequest->setRawHeader("Authorization", "Basic " + QByteArray(QString("%1:%2").arg("genesis").arg("upload").toAscii()).toBase64());
uploadEbookRequest->setRawHeader("Connection","keep-alive");
uploadEbookRequest->setRawHeader("Keep-Alive","115");
uploadEbookRequest->setRawHeader("User-Agent","Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2) Gecko/20100115 Firefox/3.6");
QString host("free-books.dontexist.org");
uploadEbookRequest->setRawHeader("Host",host.toAscii());
uploadEbookRequest->setRawHeader("Referer","http://free-books.dontexist.com/librarian/");
uploadEbookReply *uplEbookReplyManager;
QNetworkReply *uplEbookReply;
// QFile file("out.txt");
// if (!file.open(QIODevice::WriteOnly))
// return;
//.........这里部分代码省略.........
开发者ID:lgsoft-developers,项目名称:lguploader,代码行数:101,代码来源:guBookUploader.cpp
示例8: QString
void WebPage::setUserStylesheet() {
QString data = QString("*, :before, :after { font-family: 'Arial' ! important; }").toUtf8().toBase64();
QUrl url = QUrl(QString("data:text/css;charset=utf-8;base64,") + data);
settings()->setUserStyleSheetUrl(url);
}
开发者ID:toshiaki-koshiba,项目名称:capybara-webkit,代码行数:5,代码来源:WebPage.cpp
示例9: networkProcess
inline void KNMusicLyricsDownloader::networkProcess(int type,
const QString &url,
QByteArray &responseData,
const QByteArray ¶meter,
const QVariant &cookie,
const QString &referer)
{
//Stop the timer.
m_timeout->stop();
//Clear the data first.
responseData.clear();
m_networkManager->clearAccessCache();
//Generate the request.
QNetworkRequest currentRequest;
//Set the data to request.
currentRequest.setUrl(QUrl(url));
if(!cookie.isNull())
{
currentRequest.setHeader(QNetworkRequest::CookieHeader,
cookie);
}
if(!referer.isEmpty())
{
currentRequest.setRawHeader("Referer", referer.toStdString().data());
currentRequest.setRawHeader("Origin", referer.toStdString().data());
}
//Generate the reply and quit handler.
QNetworkReply *currentReply=nullptr;
KNConnectionHandler quiterHandle;
//Wait for response, using the event loop, generate the loop.
QEventLoop stuckWaitingLoop;
//Link the finished and timeout counter to quit loop.
quiterHandle+=connect(m_networkManager, SIGNAL(finished(QNetworkReply*)),
&stuckWaitingLoop, SLOT(quit()));
quiterHandle+=connect(m_timeout, SIGNAL(timeout()),
&stuckWaitingLoop, SLOT(quit()));
//Do GET.
switch(type)
{
case Post:
{
currentRequest.setHeader(QNetworkRequest::ContentTypeHeader,
"application/x-www-form-urlencoded");
currentRequest.setHeader(QNetworkRequest::ContentLengthHeader,
parameter.size());
currentReply=m_networkManager->post(currentRequest, parameter);
break;
}
case Get:
{
currentReply=m_networkManager->get(currentRequest);
break;
}
}
//Start counting.
m_timeout->start();
//Start loop.
stuckWaitingLoop.exec();
//Disconnect all the links.
quiterHandle.disconnectAll();
//Check if there's reply.
if(currentReply==nullptr)
{
return;
}
//Get the data.
responseData=currentReply->readAll();
//Clear the reply.
delete currentReply;
}
开发者ID:loki1412,项目名称:Mu,代码行数:70,代码来源:knmusiclyricsdownloader.cpp
示例10: toURL
QUrl toURL(const std::string& s) {
return QUrl(toQString(s));
}
开发者ID:Anto-F,项目名称:OpenStudio,代码行数:3,代码来源:URLHelpers.cpp
示例11: refreshMap
void TopologyDialog::refreshMap()
{
ui->webView->load(QUrl("qrc:/final.html"));
ui->webView->show();
}
开发者ID:bigpotato920,项目名称:topology,代码行数:5,代码来源:topologydialog.cpp
示例12: atoi
void Check_for_updates::replyFinished()
{
long long int n;
char buf[128];
int this_version,
latest_version;
QNetworkReply *reply = qobject_cast<QNetworkReply *>(sender());
if(reply->error() != QNetworkReply::NoError)
{
reply->deleteLater();
return;
}
if(reply->bytesAvailable() < 31)
{
reply->deleteLater();
return;
}
n = reply->read(buf, 100);
if(n < 31)
{
reply->deleteLater();
return;
}
reply->deleteLater();
buf[30] = 0;
if(strncmp(buf, "EDFbrowser latest version: ", 27))
{
return;
}
if(is_integer_number(buf + 27))
{
return;
}
latest_version = atoi(buf + 27);
if((latest_version < 1) || (latest_version > 1000000))
{
return;
}
sprintf(buf, PROGRAM_VERSION);
buf[1] = buf[0];
this_version = atoi(buf + 1);
if(this_version >= latest_version)
{
return;
}
QMessageBox messagewindow(QMessageBox::Information,
"New version available",
"A newer version of EDFbrowser is available.\n"
"Do you want to download the new version now?",
QMessageBox::Yes | QMessageBox::No);
if(messagewindow.exec() != QMessageBox::Yes)
{
return;
}
QDesktopServices::openUrl(QUrl("http://www.teuniz.net/edfbrowser/"));
}
开发者ID:pangratz,项目名称:EDFbrowser,代码行数:79,代码来源:check_for_updates.cpp
示例13: defined
/** @brief detects current system proxy
* @return QUrl with proxy or empty
*/
QUrl System::systemProxy(void)
{
#if defined(Q_OS_LINUX)
return QUrl(getenv("http_proxy"));
#elif defined(Q_OS_WIN32)
HKEY hk;
wchar_t proxyval[80];
DWORD buflen = 80;
long ret;
DWORD enable;
DWORD enalen = sizeof(DWORD);
ret = RegOpenKeyEx(HKEY_CURRENT_USER,
_TEXT("Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings"),
0, KEY_QUERY_VALUE, &hk);
if(ret != ERROR_SUCCESS) return QUrl("");
ret = RegQueryValueEx(hk, _TEXT("ProxyServer"), NULL, NULL, (LPBYTE)proxyval, &buflen);
if(ret != ERROR_SUCCESS) return QUrl("");
ret = RegQueryValueEx(hk, _TEXT("ProxyEnable"), NULL, NULL, (LPBYTE)&enable, &enalen);
if(ret != ERROR_SUCCESS) return QUrl("");
RegCloseKey(hk);
//qDebug() << QString::fromWCharArray(proxyval) << QString("%1").arg(enable);
if(enable != 0)
return QUrl("http://" + QString::fromWCharArray(proxyval));
else
return QUrl("");
#elif defined(Q_OS_MACX)
CFDictionaryRef dictref;
CFStringRef stringref;
CFNumberRef numberref;
int enable = 0;
int port = 0;
unsigned int bufsize = 0;
char *buf;
QUrl proxy;
dictref = SCDynamicStoreCopyProxies(NULL);
if(dictref == NULL)
return proxy;
numberref = (CFNumberRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPEnable);
if(numberref != NULL)
CFNumberGetValue(numberref, kCFNumberIntType, &enable);
if(enable == 1) {
// get proxy string
stringref = (CFStringRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPProxy);
if(stringref != NULL) {
// get number of characters. CFStringGetLength uses UTF-16 code pairs
bufsize = CFStringGetLength(stringref) * 2 + 1;
buf = (char*)malloc(sizeof(char) * bufsize);
if(buf == NULL) {
qDebug() << "[System] can't allocate memory for proxy string!";
CFRelease(dictref);
return QUrl("");
}
CFStringGetCString(stringref, buf, bufsize, kCFStringEncodingUTF16);
numberref = (CFNumberRef)CFDictionaryGetValue(dictref, kSCPropNetProxiesHTTPPort);
if(numberref != NULL)
CFNumberGetValue(numberref, kCFNumberIntType, &port);
proxy.setScheme("http");
proxy.setHost(QString::fromUtf16((unsigned short*)buf));
proxy.setPort(port);
free(buf);
}
}
CFRelease(dictref);
return proxy;
#else
return QUrl("");
#endif
}
开发者ID:4nykey,项目名称:rockbox,代码行数:80,代码来源:system.cpp
示例14: QWebPage
PageRunner::PageRunner(const QStringList& args)
: QWebPage(0),
out(stdout),
err(stderr),
view(new QWidget()) {
QMap<QString, QString> settings = parseArguments(args);
QStringList arguments = args.mid(settings.size() * 2);
exportpdf = settings.value("export-pdf");
exportpng = settings.value("export-png");
url = QUrl(arguments[0]);
nativeio = new NativeIO(this, QFileInfo(arguments[0]).dir(),
QDir::current());
if (url.scheme() == "file" || url.isRelative()) {
QFileInfo info(arguments[0]);
url = QUrl::fromLocalFile(info.absoluteFilePath());
if (!info.isReadable() || !info.isFile()) {
QTextStream err(stderr);
err << "Cannot read file '" + url.toString() + "'.\n";
qApp->exit(1);
}
}
nam = new NAM(this, QUrl(url).host(), QUrl(url).port());
setNetworkAccessManager(nam);
connect(this, SIGNAL(loadFinished(bool)), this, SLOT(finished(bool)));
connect(mainFrame(), SIGNAL(javaScriptWindowObjectCleared()),
this, SLOT(slotInitWindowObjects()));
sawJSError = false;
setView(view);
scriptMode = arguments[0].endsWith(".js");
if (scriptMode) {
QByteArray html = "'" + arguments[0].toUtf8().replace('\'', "\\'")
+ "'";
for (int i = 1; i < arguments.length(); ++i) {
html += ",'" + arguments[i].toUtf8().replace('\'', "\\'") + "'";
}
html = "<html>"
"<head><title></title>"
"<script>var arguments=[" + html + "];</script>"
"<script src=\"" + arguments[0].toUtf8() + "\"></script>";
// add runtime modification
html += "<script>//<![CDATA[\n" + getRuntimeBindings() +
"if (typeof(runtime) !== 'undefined' && typeof(nativeio) !== 'undefined') {\n"
" runtime.libraryPaths = function () {"
" /* convert to javascript array */"
" var p = nativeio.libraryPaths(),"
" a = [], i;"
" for (i in p) { a[i] = p[i]; }"
" return a;"
" };}//]]></script>";
html += "</head><body></body></html>\n";
QTemporaryFile tmp("XXXXXX.html");
tmp.setAutoRemove(true);
tmp.open();
tmp.write(html);
tmp.close();
QFileInfo info(tmp.fileName());
mainFrame()->load(QUrl::fromLocalFile(info.absoluteFilePath()));
} else {
// Make the url absolute. If it is not done here, QWebFrame will do
// it, and it will lose the query and fragment part.
QUrl absurl;
if (url.isRelative()) {
absurl = QUrl::fromLocalFile(QFileInfo(url.toLocalFile()).absoluteFilePath());
absurl.setQueryItems(url.queryItems());
absurl.setFragment(url.fragment());
} else {
absurl = url;
}
mainFrame()->load(absurl);
}
}
开发者ID:KopBob,项目名称:WebODF,代码行数:74,代码来源:pagerunner.cpp
示例15: loadURL
bool WebPage::loadURL(const QString link){
// No need for network test, will be done in urlChanged
b->loadurl(QUrl(link));
return true;
}
开发者ID:FlatTurtle,项目名称:InfoScreenBrowser,代码行数:5,代码来源:webpage.cpp
示例16: QUrl
void HTMLPreview::displayURL()
{
QUrl url = QUrl(ui->url->text());
ui->webView->load(url);
}
开发者ID:dd32,项目名称:PonyEdit,代码行数:5,代码来源:htmlpreview.cpp
示例17: setUpdatesEnabled
void RunningScriptsWidget::setRunningScripts(const QStringList& list) {
setUpdatesEnabled(false);
QLayoutItem* widget;
while ((widget = ui->scriptListWidget->layout()->takeAt(0)) != NULL) {
delete widget->widget();
delete widget;
}
QHash<QString, int> hash;
const int CLOSE_ICON_HEIGHT = 12;
for (int i = 0; i < list.size(); i++) {
if (!hash.contains(list.at(i))) {
hash.insert(list.at(i), 1);
}
QWidget* row = new QWidget(ui->scriptListWidget);
row->setLayout(new QHBoxLayout(row));
QUrl url = QUrl(list.at(i));
QLabel* name = new QLabel(url.fileName(), row);
if (hash.find(list.at(i)).value() != 1) {
name->setText(name->text() + "(" + QString::number(hash.find(list.at(i)).value()) + ")");
}
++hash[list.at(i)];
QPushButton* closeButton = new QPushButton(row);
closeButton->setFlat(true);
closeButton->setIcon(
QIcon(QPixmap(Application::resourcesPath() + "images/kill-script.svg").scaledToHeight(CLOSE_ICON_HEIGHT)));
closeButton->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred));
closeButton->setStyleSheet("border: 0;");
closeButton->setCursor(Qt::PointingHandCursor);
connect(closeButton, SIGNAL(clicked()), &_signalMapper, SLOT(map()));
_signalMapper.setMapping(closeButton, url.toString());
row->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
row->layout()->setContentsMargins(4, 4, 4, 4);
row->layout()->setSpacing(0);
row->layout()->addWidget(name);
row->layout()->addWidget(closeButton);
row->setToolTip(url.toString());
QFrame* line = new QFrame(row);
line->setFrameShape(QFrame::HLine);
line->setStyleSheet("color: #E1E1E1; margin-left: 6px; margin-right: 6px;");
ui->scriptListWidget->layout()->addWidget(row);
ui->scriptListWidget->layout()->addWidget(line);
}
ui->noRunningScriptsLabel->setVisible(list.isEmpty());
ui->reloadAllButton->setVisible(!list.isEmpty());
ui->stopAllButton->setVisible(!list.isEmpty());
ui->scriptListWidget->updateGeometry();
setUpdatesEnabled(true);
Application::processEvents();
repaint();
}
开发者ID:RyanDowne,项目名称:hifi,代码行数:61,代码来源:RunningScriptsWidget.cpp
示例18: QUrl
QUrl GameStorage::getFileDirectory() const {
QUrl dir = QUrl(QStandardPaths::writableLocation(QStandardPaths::AppDataLocation));
qDebug() << dir;
return dir;
}
开发者ID:huzecong,项目名称:GomokuDuel,代码行数:5,代码来源:gamestorage.cpp
示例19: QUrl
void TelegramGui::openFile(const QString &file)
{
QDesktopServices::openUrl( QUrl(file) );
}
开发者ID:Ken2713,项目名称:sigram,代码行数:4,代码来源:telegramgui.cpp
示例20: QUrl
// SPDX-License-Identifier: GPL-2.0
#include <QQmlContext>
#include <QDebug>
#include <QQuickItem>
#include <QModelIndex>
#include "mapwidget.h"
#include "core/divesite.h"
#include "map-widget/qmlmapwidgethelper.h"
#include "qt-models/maplocationmodel.h"
#include "qt-models/divelocationmodel.h"
#include "mainwindow.h"
#include "divelistview.h"
#include "command.h"
static const QUrl urlMapWidget = QUrl(QStringLiteral("qrc:/qml/MapWidget.qml"));
static const QUrl urlMapWidgetError = QUrl(QStringLiteral("qrc:/qml/MapWidgetError.qml"));
static bool isReady = false;
#define CHECK_IS_READY_RETURN_VOID() \
if (!isReady) return
MapWidget *MapWidget::m_instance = NULL;
MapWidget::MapWidget(QWidget *parent) : QQuickWidget(parent)
{
m_rootItem = nullptr;
m_mapHelper = nullptr;
setResizeMode(QQuickWidget::SizeRootObjectToView);
connect(this, &QQuickWidget::statusChanged, this, &MapWidget::doneLoading);
connect(&diveListNotifier, &DiveListNotifier::divesChanged, this, &MapWidget::divesChanged);
开发者ID:dirkhh,项目名称:subsurface,代码行数:31,代码来源:mapwidget.cpp
注:本文中的QUrl函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论