qt5

How to set animated icon to QPushButton in Qt5?

佐手、 提交于 2020-02-17 07:44:28
问题 QPushButton can have icon, but I need to set animated icon to it. How to do this? I created new class implemented from QPushButton but how to replace icon from QIcon to QMovie ? 回答1: This can be accomplished without subclassing QPushButton by simply using the signal / slot mechanism of Qt. Connect the frameChanged signal of QMovie to a custom slot in the class that contains this QPushButton . This function will apply the current frame of the QMovie as the icon of the QPushButton . It should

Qt5基于smtp服务发送电子邮件

做~自己de王妃 提交于 2020-02-17 05:37:41
1、设置邮箱 先登录163邮箱,然后在邮箱界面找到设置,在里面开通smtp服务。 这一步比较关键,要开通smtp服务,在开通的过程中会让你输入一个邮箱客户端授权码,这个才是你后面要用到的密码,而不是你登陆邮箱的密码; 2. telnet命令发送邮件 打开cmd. 1. 输入 telnet smtp.163.com 25 回车 我试验了好几个邮箱服务器,大都有严厉的反垃圾邮件系统,导致邮件发不出去,幸好163的邮箱竟然可以.TX威武呀.smtp的协议端口为25. 2. 输入 HELO smtp.163.com 回车 我搜集的一些资料中既有使用helo又有使用ehlo的,结果还使我纠结了好久,后来又google才知道,原来都可以.这句应该是与服务器打招呼.如果返回250表示服务器准备就绪,可以进行下一步了. 3. 输入 AUTH LOGIN 回车 这是指定登录的模式,这句应该是一般模式.返回334就可以进行下一步了. 4. 输入 经过base64加密的你的账户名,比如你的邮箱账号号是xxxxxx@163.com,就去百度下 base64加密这个邮箱账号(是加密整个邮箱账号),copy到命令行回车返回334 5.输入对应的授权码(base64加密这个授权码),注意是163邮箱的授权码,不是密码。回复235 Authentication successful表示验证通过,可以进行下一步了.

解决 Qt5 报错 This application failed to start because it could not find or load the Qt platform plugin

ぐ巨炮叔叔 提交于 2020-02-16 11:37:05
QT为了简化生成发布版本,特别提供了工具 "windeplayqt.exe",这个工具在 "...\Qt5.8.0\5.8\msvc2015_64\bin"的目录下,通过该命令,可以解决上述错误。 打开控制台窗口 设置搜索路径以便系统可以搜索到 "windeployqt.exe" 运行 "windeplayqt.exe D:\work\project\sample\bin\Release\sample.exe", 所需要的QT运行库就自动拷贝到目标程序目录了。 其他 以上方法也适合debug版本。 如果程序使用了新的QT模块,重新执行一遍即可 来源: https://www.cnblogs.com/zhousong918/p/9934952.html

ubuntu18.04.3新装系统安装QT5.14.1和环境配置

左心房为你撑大大i 提交于 2020-02-07 16:14:25
第一步:下载QT: http://download.qt.io/archive/qt/ 或者 https://mirrors.tuna.tsinghua.edu.cn/qt/archive/qt/ 下载 qt-opensource-linux-x64-5.14.1.run 第二步: 修改软件权限: chomd 755 qt-opensource-linux-x64-5.14.1.run 第三步:安装软件: 运行软件:./ qt-opensource-linux-x64-5.14.1.run 接着按着提示装软件就可以了。 值得注意的是:在选择安装组件时勾选这个就可以 Desktop gcc 64-bit 这是Qt预编译好的64位的Qt库。 Developer and Designer Tools 这就是我们的主角QtCreator Qt WebEngine 这是Qt替代Webkit的库,这个装不装都行。 第四步:配置环境变量: 打开文件 vim /etc/profile 在文件的末尾添加: export PATH="/opt/Qt5.14.1/Tools/QtCreator/bin:$PATH" export PATH="/opt/Qt5.14.1/5.14.1/gcc_64/bin:$PATH" source /etc/profile 说明:本人的安装目录在opt

Trouble sending Data with QSerialPort

有些话、适合烂在心里 提交于 2020-02-04 09:30:26
问题 I am trying to write a QT application that can communicate with a propeller over USB. Reading through the documentation QSerialPort seems to be exactly what I need. For a simple test, I am trying to send the number "2" to my propeller project. The project itself has its own OLED screen that I can read results on. Here is the QT code itself: this->Serial=new QSerialPort(this); this->Serial->setPortName("/dev/ttyUSB0"); this->Serial->setBaudRate(QSerialPort::Baud9600); connect(this->Serial

Qt5 QML, when to use a ColumnLayout vs Column?

生来就可爱ヽ(ⅴ<●) 提交于 2020-02-01 00:34:07
问题 For example, this works: import QtQuick 2.5 import QtQuick.Controls 1.4 import QtQuick.Controls.Styles 1.4 import QtQuick.Layouts 1.2 ApplicationWindow { visible: true width: 640 height: 480 title: qsTr("Hello World") function thingWidth() { return width*80/100 } Column { spacing: 10; anchors.horizontalCenter: parent.horizontalCenter Thing { color: "red"; width: thingWidth(); } Thing { color: "yellow"; width: thingWidth(); } Thing { color: "green"; width: thingWidth(); } } } But change Column

QWidget::paintEngine: Should no longer be called in a QTreeWidget derived class [duplicate]

為{幸葍}努か 提交于 2020-01-30 13:14:08
问题 This question already has answers here : paintEvent in QTableView derived class: Paint device returned engine == 0, type: 1 (1 answer) Warning QPainter inside paintEvent [duplicate] (1 answer) Closed 2 years ago . I have a class, MyTree , which derived from QTreeWidget and void MyTree::paintEvent(QPaintEvent *event) { QPainter painter(this); } causes to raise the following issue, QWidget::paintEngine: Should no longer be called QPainter::begin: Paint device returned engine == 0, type: 1 Could

create tutorial mode

空扰寡人 提交于 2020-01-30 11:47:30
问题 I have a Qt application and want to show a little tutorial when the user access the application for the first time. Something like this: How can I do something like this on Qt? I'm using Qt 5.4 on Windows. 回答1: To perform this task we must make the translucent background, we do it by activating the attribute Qt::WA_TranslucentBackground , then we use QPainterPath to draw the rectangle minus the transparent circle. Then use eventFilter to know some events like when they are displayed, if you

Using a qml type as a QWindow in C++ code

谁说我不能喝 提交于 2020-01-30 08:51:07
问题 I've created a MainWindow : public QMainWindow and a qtquick ui file (for a toolbox) in qtcreator. I want the toolbox to appear as a floating subwindow in mainwindow. I'm trying to use QMdiArea for that. A tutorial I've seen says that I need to add a window to the QMdiArea like this: mdi->addSubWindow(win); where win is a QWidget . How do I use the toolbox created with qml in my C++ code? 回答1: You can use QQuickWidget but remember that the root of the QML must be an Item or a class that

Using a qml type as a QWindow in C++ code

邮差的信 提交于 2020-01-30 08:50:46
问题 I've created a MainWindow : public QMainWindow and a qtquick ui file (for a toolbox) in qtcreator. I want the toolbox to appear as a floating subwindow in mainwindow. I'm trying to use QMdiArea for that. A tutorial I've seen says that I need to add a window to the QMdiArea like this: mdi->addSubWindow(win); where win is a QWidget . How do I use the toolbox created with qml in my C++ code? 回答1: You can use QQuickWidget but remember that the root of the QML must be an Item or a class that