本文整理汇总了C++中QUrl函数的典型用法代码示例。如果您正苦于以下问题:C++ QUrl函数的具体用法?C++ QUrl怎么用?C++ QUrl使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QUrl函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QUrl
void
MainWindow::openSubIssue(void)
{
QDesktopServices::openUrl(
QUrl("https://github.com/rtxi/rtxi/issues", QUrl::TolerantMode));
}
示例2: setLoginUrl
void LoginDialog::setLoginUrl(const QString& url)
{
//ui->webView->setUrl(QUrl(""));
ui->webView->setUrl(QUrl(url));
}
示例3: QUrl
QUrl PasswordsContentsWidget::getUrl() const
{
return QUrl(QLatin1String("about:passwords"));
}
示例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()])));
}
示例5: resolveUrl
inline QUrl resolveUrl(const QString &url) const
{ return resolveUrl(QUrl(url)); }
示例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();
}
示例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;
//.........这里部分代码省略.........
示例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);
}
示例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;
}
示例10: toURL
QUrl toURL(const std::string& s) {
return QUrl(toQString(s));
}
示例11: refreshMap
void TopologyDialog::refreshMap()
{
ui->webView->load(QUrl("qrc:/final.html"));
ui->webView->show();
}
示例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/"));
}
示例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
}
示例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);
}
}
示例15: loadURL
bool WebPage::loadURL(const QString link){
// No need for network test, will be done in urlChanged
b->loadurl(QUrl(link));
return true;
}