安裝qt 6.6.2的mqtt還是官方的吧,能很好融入進開發系統中,直接調用,一直很好用,下面把折磨人的安裝方法分享一下,之所以說折磨人,主要是qt 6以后的插件安裝采用cmake,原來一直用qmake開發的,不大好上手。
一 下載地址
參考上篇博客,選中6.6.2版本下載就行
二 打開工程直接報錯
報錯如下:
E:\Qt\Tools\CMake_64\share\cmake-3.24\Modules\CMakeTestCXXCompiler.cmake:62: error: The C++ compiler "d:/Program Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/HostX64/x64/cl.exe" is not able to compile a simple test program. It fails with the following output: Change Dir: E:/mywork/programme/TEST/build-untitled01-Desktop_Qt_6_6_2_MSVC2019_64bit-Release/CMakeFiles/CMakeTmp Run Build Command(s):D:/Program Files/Microsoft Visual Studio/2022/Community/Common7/IDE/CommonExtensions/Microsoft/CMake/Ninja/ninja.exe cmTC_e19da && [1/2] Building CXX object CMakeFiles\cmTC_e19da.dir\testCXXCompiler.cxx.obj [2/2] Linking CXX executable cmTC_e19da.exe FAILED: cmTC_e19da.exe cmd.exe /C "cd . && E:\Qt\Tools\CMake_64\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_e19da.dir --rc=Ninja --mt="D:\Windows Kits\bin.0.20348.0\x64\mt.exe" --manifests -- "D:\Program Files\Microsoft Visual Studio22\Community\VC\Tools\MSVC.33.31629\bin\Hostx64\x64\link.exe" /nologo CMakeFiles\cmTC_e19da.dir\testCXXCompiler.cxx.obj /out:cmTC_e19da.exe /implib:cmTC_e19da.lib /pdb:cmTC_e19da.pdb /version:0.0 /machine:x64 /debug /INCREMENTAL /subsystem:console kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib && cd ." RC Pass 1: command "Ninja /fo CMakeFiles\cmTC_e19da.dir/manifest.res CMakeFiles\cmTC_e19da.dir/manifest.rc" failed (exit code 1) with the following output: ninja: error: unknown target '/fo', did you mean 'all'? ninja: build stopped: subcommand failed.
------------------------------------------------------------------------------------------------------------------------
實際就是沒有安裝好編譯器,等諸多配置環境
打開項目,編譯配置一下:
添加一句話:
Files/Microsoft Visual Studio/2022/Community/VC/Tools/MSVC/14.33.31629/bin/Hostx64/x64/lib.exe
然后重新配置一下:
可以編譯了,最后得到如下結果:
三 安裝與測試
把上面這些文件夾的內容,分別復制到qt對應安裝目錄中,直接可以使用了;
如上面所示,用qt自己的例子,測試成功!
QtAcrylic 是一個 Python 模塊,它可以將 Windows 10 的 Acrylic 材質主題應用到你的 PyQt/PySide 窗口上。它還能讓你使用 Aero 材質主題,為你的應用程序帶來更現代、更吸引人的視覺效果。
QtAcrylic 的優勢
使用 QtAcrylic 的步驟
示例代碼
以下是一個使用 QtAcrylic 應用 Acrylic 效果的示例代碼:
from PySide2.QtWidgets import QWidget, QApplication
from qtacrylic import WindowEffect # 導入 QtAcrylic 模塊
from PySide2 import QtWidgets
from PySide2.QtCore import Qt
from PySide2.QtGui import QFont
import sys
class Window(QWidget):
def __init__(self):
super(Window, self).__init__()
self.setFixedWidth(400) # 設置窗口固定寬度
self.setFixedHeight(400) # 設置窗口固定高度
self.setWindowFlags(Qt.FramelessWindowHint) # 設置無邊框窗口
self.setAttribute(Qt.WA_TranslucentBackground) # 設置窗口半透明
self.ui_layout = QtWidgets.QGridLayout(self) # 創建布局
self.ui_layout.setAlignment(Qt.AlignCenter) # 設置布局居中
self.label = QtWidgets.QLabel("Hello World!", self) # 創建標簽
self.label.setFont(QFont("Segoe UI", 14)) # 設置標簽字體和大小
self.ui_layout.addWidget(self.label) # 將標簽添加到布局
self.windowFX = WindowEffect() # 實例化 WindowEffect 類
self.windowFX.setAcrylicEffect(self.winId()) # 應用 Acrylic 效果
if __name__ == "__main__":
app = QApplication(sys.argv)
win = Window()
win.show()
app.exec_()
注意事項
結語
QtAcrylic 是一個簡單易用的工具,可以幫助你輕松地將 Windows 10 的 Acrylic 或 Aero 材質主題應用到你的 PyQt/PySide 窗口,提升應用程序的視覺效果。如果你想讓你的應用程序更現代、更吸引人,不妨嘗試使用 QtAcrylic。
項目地址:https://github.com/blitpxl/qtacrylic