qt最后一个离线版本是
qt-opensource-windows-x86-5.14.2.exe
下载地址:
https://download.qt.io/archive/qt/5.14/5.14.2/
qt 6.4 不支持win7
只支持win10以及以后的产品。
Windows 11 21H2 (1809 or later) x86_64 MSVC 2022, MSVC 2019, MinGW 11.2
Windows 10 21H2 (1809 or later) x86_64 MSVC 2022, MSVC 2019, MinGW 11.2
也不支持x86

详细说明:
https://doc.qt.io/qt-6/supported-platforms.html

https://download.qt.io/archive/qt/5.14/5.14.2/qt-opensource-windows-x86-5.14.2.exe
https://download.qt.io/archive/qt/5.14/5.14.2/qt-opensource-mac-x64-5.14.2.dmg
https://download.qt.io/archive/qt/5.14/5.14.2/qt-opensource-linux-x64-5.14.2.run

qt5支持win7
Windows 11 21H2 x86 and x86_64
Windows 10 21H2 x86 and x86_64 MSVC 2022, MSVC 2019, MSVC 2017, MSVC 2015, MinGW 8.1
Windows 8.1 x86 and x86_64 MSVC 2019, MSVC 2017, MinGW 8.1
Windows 7 x86 and x86_64 MSVC 2019, MSVC 2017, MinGW 8.1

https://doc.qt.io/qt-5/supported-platforms.html

ubuntu qt 6.4 remove

Updating or Removing Components
Once Qt is installed, you can use the Maintenance Tool under <install_dir> to add components, update, or remove installed components.

From The Terminal:

  1. Remove the package:

    sudo apt-get remove qtcreator && sudo apt-get remove qt5*

  2. Remove all the dependencies:

    sudo apt-get purge qtcreator && sudo apt-get purge qt5*

  3. Remove the unneeded packages that were once installed as a dependency:

    sudo apt-get autoremove

  4. Remove the retrieved packages from the local cache:

    sudo apt-get autoclean

From the GUI:

Open Qt Maintenance Tool Qt Maintenance Tool
Tick Uninstall Uninstall
Click next, then Uninstall enter image description here
Enter the Sudo password if requested then, press Finish.

Qt5.14.2安装在Win7上面要11G多。

要支持xp,估计要用Qt5.6
我现在还经常在用 Qt 5.6,因为这个版本支持 winxp.
https://download.qt.io/new_archive/qt/5.6/5.6.3/
Qt5可以使用msvc编译器和mingw编译器,而msvc的编译器从2015开始就对xp的支持变差,就算通过各种编译配置命令设置,能xp下运行,但是会很可能发生一些奇奇怪怪的bug。而mingw编译器没有这个问题,同一个版本可以在xp win7 win10各个系统使用,而无需其他配置。另外,Qt5目前有两个长期支持版本(Long Term Support)Qt5.6和Qt5.9,Qt5.6可以在XP和win7及以上系统开发,而Qt5.9只支持win7以上的系统开发和部署。 所以如果想使用Qt5的新功能,又想开发出的软件能在xp系统上运行,可以选择Qt5.6的mingw-32bit版本或者vs2013版本进行开发。
1、Qt从5.7版本开始不再支持WinXP系统,即编译生成的exe文件无法在WinXP系统运行。
2、Qt5.6是长期支持版本Long Term Support,它可以支持WinXP-32bit的系统。参考:http://doc.qt.io/qt-5.6/supported-platforms.html
下载网站是:
http://download.qt.io/new_archive/qt/5.6/5.6.3/
请注意,这几个版本是完全ok的:
qt-opensource-windows-x86-msvc2013_64-5.6.3.exe
qt-opensource-windows-x86-msvc2013-5.6.3.exe
qt-opensource-windows-x86-mingw492-5.6.3.exe

https://download.qt.io/new_archive/qt/5.6/5.6.3/qt-opensource-windows-x86-msvc2013-5.6.3.exe
https://download.qt.io/new_archive/qt/5.6/5.6.3/qt-opensource-windows-x86-mingw492-5.6.3.exe
https://download.qt.io/new_archive/qt/5.6/5.6.3/qt-opensource-linux-x64-5.6.3.run

qt分发程序的问题
在将 Qt 程序构建、运行、打包之后点击生成的 exe 文件发现出现以下“ZN10QArrayData10deallocateEPS_jj无法找到入口”错误。

无法定位程序输入点_ZN10QArrayData10deallocateEPs_jj于动态链接库..... .exe上。
之后发现是因为构建项目时使用的编译工具和打包软件时使用的编译工具不一样所导致的。

打开关于release相关的文件夹,找到该目录下release目录下的.exe程序。将这个.exe文件拷贝出来,创建一个单独的文件夹,放在这个文件夹下。
从Windows图标找到Qt软件,找到相同的编译工具,打开。
在该命令行窗口中通过盘符和cd命令转到才拷贝出来的exe程序所在的目录。
使用windeployqt命令打包,即windeployqt 文件名.exe 敲击回车。这一步操作是将所需的库文件全都拷贝到exe程序的当前文件
此时程序目录如下,点击exe文件即可正常运行程序。将该目录整体拷贝到其它Windows系统中也可直接运行。
from: https://www.twblogs.net/a/5ef7ff959d5eac1aaa69bcb6/?lang=zh-cn

Qt 错误
create directory “C:UsersAdministratorDocumentsError in " Util.asciify
项目->shadow build 去掉打钩,run正常.
或者打勾,手动建立一个临时目录供编译生成。

qt ui修改不生效

办法一:
在.pro文件中加入:

UI_DIR=./

这条命令直接将ui目录指定为项目目录。

办法二:
取消影子编译,这样所有编译在项目文件夹下进行,但不同kit的程序会覆盖(其实没什么问题)

qt 修改title
setWindowTitle(ui->label->text());

qt groupbox border

解决方案:

1. 在QGroupBox控件右键;
2. 选择 Change styleSheet... 选项卡;
3. 在文本框里输入(可以通过对话框上面的Add Resource、Add Gradient、Add
    Color、Add Font快速添加属性):
    QGroupBox {
        border-color: rgb(156, 156, 156);
        border-width: 1px;
        border-style: solid;
        margin-top: 0.5ex;
    }
    QGroupBox::title {
        subcontrol-origin: margin;
        subcontrol-position: top left;
        left: 10px;
        margin-left: 2px;
        padding: 0  0px;
    }
4. 点击OK按钮;
5. 确认效果。

Qt textedit写日志效果

void Dialog::on_pushButton_clicked()
{
    //ui->label->adjustSize();
    ui->pushButton->setText("Hello World!");

    ui->textEdit->document()->setMaximumBlockCount(30);
    ui->textEdit->append("123 然后每次再追加数据,就没问题了");

}

获取ms时间字符串

#include <chrono>
#include <iomanip>
#include <iostream>

string getTimestamp() {
  // get a precise timestamp as a string
  const auto now = std::chrono::system_clock::now();
  const auto nowAsTimeT = std::chrono::system_clock::to_time_t(now);
  const auto nowMs = std::chrono::duration_cast<std::chrono::milliseconds>(
      now.time_since_epoch()) % 1000;
  std::stringstream nowSs;
  nowSs
      << std::put_time(std::localtime(&nowAsTimeT), "%a %b %d %Y %T")
      << '.' << std::setfill('0') << std::setw(3) << nowMs.count();
  return nowSs.str();
}

Qt静态编译
ActivePerl-5.22.1.2201-MSWin32-x64-299574.msi
下载地址:
https://github.com/judwhite/talks-goperf/tree/master/tools

安装(以mingw为例,下载路径为
https://download.qt.io/new_archive/qt/5.6/5.6.3/qt-opensource-windows-x86-mingw492-5.6.3.exe
qt-opensource-windows-x86-mingw492-5.6.3.exe,因为mingw免费

意安装路径不要有中文

3.修改mingw的连接器配置项为静态编译

也就是修改5.6.3\Src\qtbase\mkspecs\win32-g++\qmake.conf

将QMAKE_LFLAGS=后添加-static作为编译参数

将QMAKE_LFLAGS_DLL=-shared改为-static作为编译参数

安装编译需要的工具

根据qt官方编译windows库需要条件(https://doc.qt.io/qt-5/windows-requirements.html),需要安装Python与ActivePerl,安装完毕后,如果环境变量没有,请手动将这两个软件添加到环境变量中去。

同时请将安装目录下的Tools\mingw492_32\bin添加到环境变量中去。

运行configure

小沃运行的是如下完整命令configure.bat -c++std c++11 -platform win32-g++ -prefix C:\Qt\Qt5.6.3\5.6.3\staticlib -release -opensource -confirm-license -static -qt-zlib -qt-libpng -qt-libjpeg -qt-pcre -qt-freetype -no-qml-debug -no-openssl -no-opengl -nomake examples -nomake tests

(1)需要根据自己Qt的实际安装路径修改G:\Qt\Qt5.6.3\5.6.3\staticlib

(2)这个命令只添加了最基础的Qt支持,以下是可选修改

-opengl desktop 替换-no-opengl让其支持opengl库

-qt-zlib        压缩库,提高兼容性,可以去掉

-qt-pcre        正则表达式,提高兼容性,可以去掉

-qt-libpng      png格式图片,提高兼容性,可以去掉

-qt-libjpeg     jpeg格式图片,提高兼容性,可以去掉

-fontconfig     需要用到字体美化库时添加

7.编译

mingw32-make -j8

8为cpu核心数,这个数字最好是与cpu核心数一致,可充分利用多核特性。

8.安装

mingw32-make install

9.使用

以后使用需要将G:\Qt\Qt5.6.3\5.6.3\staticlib\bin添加到环境变量中去,然后通过qtcreate开发完毕程序后,整个程序的工程通过命令行运行如下命令即可。

qmake

mingw32-make

最后就会在工程文件下的release下看见编译出的东西了。

https://www.worldflying.cn/article-id-366.html

For example, on Ubuntu Linux systems, Qt can be compiled by several compilers such as clang or g++:

./configure -platform linux-clang
./configure -platform linux-g++
./configure -platform linux-g++-32
For Windows machines, either MinGW or Visual Studio toolchains can be used to compile Qt.

configure.bat -platform win32-g++
configure.bat -platform win32-msvc

https://doc.qt.io/qt-5/configure-options.html

Qt获取textedit内容
不同于其它控件的text()函数,QText Edit获取文本的函数为toPlainText()。

QString strTxtEdt = ui->textEdit->toPlainText();

函数原型:

QString QTextEdit::toPlainText() const;

Returns the text of the text edit as plain text.
Note: Getter function for property plainText.

Qt串口操作
头文件

#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QIODevice>
#include <QDateTime>
#include <QTimer>
#include <QByteArray>

QSerialPort *serialPort;
QByteArray RxData;

源文件

serialPort = new QSerialPort(this);
connect(serialPort, &QSerialPort::readyRead, this, &Dialog::ReadData);

foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
{
    qDebug()<<"port name"<<info.portName();
    qDebug()<<"Description"<<info.description();
    qDebug()<<"Manufacturer"<<info.manufacturer();
    ui->cbb_port->addItem(info.portName());
}    

serialPort->setPortName(ui->cbb_port->currentText());
if(serialPort->open(QIODevice::ReadWrite))
{
  add_memo_info("串口打开成功");
  ui->btn_serial->setText("关闭串口");
}
serialPort->setBaudRate(ui->cbb_bade->currentText().toInt());
serialPort->setParity(QSerialPort::NoParity);
serialPort->setDataBits(QSerialPort::Data8);
serialPort->setStopBits(QSerialPort::OneStop);
serialPort->setFlowControl(QSerialPort::NoFlowControl);

void Dialog::ReadData()
{
    RxData = serialPort->readAll();
    if(RxData.isEmpty())
    {
        add_memo_info("没有收到相应数据");
    }

    QString str =  RxData.toHex().toStdString().c_str();
    add_memo_info("recv<- " +  str);
}

bool Dialog::SendData(std::string strhex)
{
    QByteArray ba;
    string strorig = strhex;
    strhex = hex_to_string(strhex);
    ba = QByteArray::fromStdString(strhex);
    int ret = serialPort->write(ba);
    if(ret>0)
    {
        return true;
    }
    else
    {
        return false;
    }
}

QT使用资源管理器打开目录

QString str = QCoreApplication::applicationDirPath();
QDesktopServices::openUrl(QUrl(str, QUrl::TolerantMode));

也可以使用

QDesktopServices::openUrl(QUrl::fromLocalFile(qApp->applicationDirPath()));

qt folder exists
To check if a directory named "Folder" exists use:

QDir("Folder").exists();

To create a new folder named "MyFolder" use:

QDir().mkdir("MyFolder");

Qt支持openssl

wget https://www.openssl.org/source/old/1.0.2/openssl-1.0.2u.tar.gz
tar xvf openssl-1.0.2u.tar.gz
cd openssl-1.0.2
./config enable-shared
make -j4
cp libssl.so* libcrypto.so* ~/Qt5.6.3/5.6.3/gcc_64/lib/ -a

代码中检测SSL

 qDebug()<<QSslSocket::supportsSsl();
 qDebug()<<QSslSocket::sslLibraryVersionString();

true
"OpenSSL 1.0.2u 20 Dec 2019"

本文链接地址:https://const.net.cn/738.html

标签: none

添加新评论