Qt之QDesktopServices 和 QStandardPaths
1、開啟瀏覽器網頁
QUrl url(QString("www.google.com"));
bool is_open = QDesktopServices::openUrl(url);
2、開啟本地檔案(夾)、可執行程式等
QString local_path = QString("E:/新建資料夾"); //a.txt、a.exe、a.mp3、a.mp4、a.rmvb等
QString path = QString("file:///") + local_path;
bool is_open = QDesktopServices::openUrl(QUrl(path, QUrl::TolerantMode));
注意:這裡local_path可以是檔案(夾)路徑、可執行程式路徑,當為檔案時,會選擇預設開啟方式進行開啟!
3、獲取桌面、我的文件、Home等目錄的路徑
QStandardPaths::standardLocations 獲得各種路徑。
QCoreApplication::applicationDirPath() 獲得可執行檔案的路徑。
相關推薦
Qt之QDesktopServices 和 QStandardPaths
1、開啟瀏覽器網頁 QUrl url(QString("www.google.com")); bool is_open = QDesktopServices::openUrl(url); 2、開啟本地檔案(夾)、可執行程式等 QString local_path = QString(
Qt 之 qwt 和 qwtpolar
shu fix style file ins nmake con http com 1 qwt 1.1 下載 qwt-6.1.3 版本下載地址: https://sourceforge.net/projects/qwt/files/qwt/ 1.2 解壓
【golang-GUI開發】qt之signal和slot(一)
類型 取消 htm return 所在 turn hang nbsp type 想了很久,我決定還是先從signal和slot(信號槽)開始講起。 signal和slot大家一定不陌生,先看一段示例(選自文檔): 1 class Counter : public QOb
QT---之Q_D和d指標概念2
Qt為了使其動態庫最大程度上實現二進位制相容,引入了d指標的概念。那麼為什麼d指標能實現二進位制相容呢?為了回答這個問題,首先弄清楚什麼是二進位制相容?所謂二進位制相容動態庫,指的是一個在老版本庫下執行的程式,在不經過編譯的情況下,仍然能夠在新的版本庫下執行;需要經過編譯才能在新版本下執行,而不需要
QT---之訊號和槽的關聯與語法
一概述 二訊號 四訊號和槽的關聯 五元物件工具 六程式樣例 七應注意的問題 8訊號和槽也不能攜帶模板類引數 9巢狀的類不能位於訊號或槽區域內也不能有訊號或槽
QT之C++和QML混合程式設計學習筆記
QML中使用C++物件 建立一個測試用的C++物件 #ifndef PIECHART_H #define PIECHART_H #include <QtQuick/QQuickPaintedItem> #include <QColor> #include <
Qt 之 QHttpPart 和 QHttpMultiPart
簡述 HTTP 協議對 MIME 型別有詳細描述,multipart/... 是單個訊息頭包含多個訊息體的解決方案,multipart 型別對傳送非文字型別非常有用。 | multipart 子型別 首先,來看 QHttpMultiPart 中關於 m
QT之程序和程序間通訊(IPC)
程序是作業系統的基礎之一。一個程序可以認為是一個正在執行的程式。我們可以把程序當做計算機執行時的一個基礎單位。關於程序的討論已經超出了本章的範疇,現在我們假定你是瞭解這個概念的。 在 Qt 中,我們使用QProcess來表示一個程序。這個類可以允許我們的應用程式開啟一個新的外部程式
QT之exe和dll打包方法
剛開始接觸Qt,發現mac平臺直接release編譯一下就能夠直接生成.app檔案,並且可以直接執行。.app位於工程檔案內。 同樣發方法在Windows直接執行exe卻出現缺失dll情況。 講過網上查詢,找到了一種比較好的封裝方法,將dll與exe一起封裝。記錄下來以便以後備用。
Qt 之 QDesktopServices
簡述 QDesktopServices類提供的函式用於訪問常見的桌面服務。 許多桌面環境都會提供一系列服務,可以通過應用程式來執行常見任務,如:以使用者應用程式首選項的方式,開啟一個網頁。 此類包含為服務提供簡單介面的函式,返回值表明執行成功或失敗。 o
【Qt Tips】QLineEdit內容過濾之setValidator和setInputMask淺析
neo 淺析 utm bsp edit ips put nbsp ida 1、QValidator分析 2、InputMask格式 3、測試代碼和用例 項目路徑: GitHub: https://github.com/Qunero/NeoQtTestDe
QT之INI檔案和登錄檔操作方法學習筆記
INI檔案格式 節[section] 引數(KEY/VALUE) name=value 註釋 註釋使用分號表示(;)。在分號後面的文字,直到該行結尾都全部為註釋 QCoreApplication::applicationDirPath()為應用程式當前的絕
24小時學通Qt之第四學時:槽和訊號
一、問題與答案 1、編譯器報告未找到connect()函式,為什麼? 答:如果呼叫connect()函式而未定義從哪個類中查詢它,將出現這種錯誤。這種呼叫必須在一個QObject派生類的方法內。如果從一個外部函式中呼叫,必須這樣: QObject::connect(); 2、編譯器報
Qt網路程式設計之QNetworkRequest和QNetworkReply例項(四)
設想有如下場景:輸入若干的url,然後依次的下載並存儲到檔案。本案例使用QNetworkRequest和QNetworkReply。原始碼如下: 案例原始碼 標頭檔案 #pragma once //////////////////////////////////
Qt中delete和deleteLater()的使用區別事例之QMenu關閉父介面
delete是C++的關鍵字識別符號,而deleteLater是QT中特有的,繼承QObject的類都擁有該方法。兩者主要區別是delete會馬上銷燬目標物件的,而並沒有將物件立即銷燬,而是向主訊息迴圈傳送了一個event,下一次主訊息迴圈收到這個event之後才會銷燬物件。
Qt之執行緒和QObject
前面兩個章節我們從事件迴圈和執行緒類庫兩個角度闡述有關執行緒的問題。本章我們將深入執行緒間得互動,探討執行緒和QObject之間的關係。在某種程度上,這才是多執行緒程式設計真正需要注意的問題。 現在我們已經討論過事件迴圈。我們說,每一個 Qt 應用程式至
Qt之判斷版本號巨集「QT_VERSION」和「QT_VERSION_CHECK」
栗子: void QUIWidget::setCode() { #if (QT_VERSION <= QT_VERSION_CHECK(5,0,0)) #if _MSC_VER QTextCodec *codec = QTextCodec::codecFor
Qt 之 Concurrent Map 和 Map-Reduce
簡述 QtConcurrent::map()、QtConcurrent::mapped() 和 QtConcurrent::mappedReduced() 函式對一個序列中(例如:QList、QVector)的專案並行地進行計算。QtConcurrent::m
Qt之訊號signals和槽slots詳解
學習到自定義訊號和槽的時候經常編譯不過去,前邊一篇解決了Q_OBJECT編譯的問題,這裡詳細說明了slots和signals。 1、signals前面不可加public、private和protected進行修飾;slots前面可以
Qt學習:三維繪圖之OpenGL和Qt的結合
OpenGL是繪製三維圖形的標準API。Qt應用程式可以使用QtOpenGL模組繪製三維圖形,該模組依賴於系統的OpenGL庫。Qt OpenGL模組提供QGLWidget類,可以通過對它子類化,並使用OpenGL命令開發出自己的視窗部件。對許多三維應用程式