Qt对Html富文本支持的控件以及QLabel两种打开超链接的方式

带超链接的Tableview 在TableView中插入插连接的一种办法 阅读详情


原创文章,欢迎转载。转载请注明:转载自 祥的博客

原文链接:https://blog.csdn.net/humanking7/article/details/80685893



1.说明

Qt的文本窗体部件能够显示富文本,使用HTML4 标记。能够以这种方式显示富文本的窗体控件有: QTextDocument, 以及 QLabel and QTextEdit。

Qt’s text widgets are able to display rich text, specified using a subset of HTML4 markup. Widgets that use QTextDocument, such as QLabel and QTextEdit, are able to display rich text specified in this way.

2.演示

pic1

2.1. 代码

#include <QtWidgets/QApplication>
#include <QLabel>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QString str;
    str = QString("<h1><i>Hello</i> <font color = red>Qt!</font></h1><h2>My CSDN blog: <a href=\"https://blog.csdn.net/humanking7\">https://blog.csdn.net/humanking7 </a></h2>");
    QLabel *lab = new QLabel(str);
    lab->setOpenExternalLinks(true);//如果没有这句,就只能通过linkActivated信号,连接到自定义槽函数中打开      
    lab->setWindowTitle("Test Html support");
    lab->show();

    return a.exec();
}

2.2. 关于打开超链接的两种方式说明

  1. 简单方式,用Qt自带的setOpenExternalLinks(true)函数进行设置;
  2. 用通过linkActivated信号,连接到自定义槽函数中打开超链接。

用第二种方式实现超链接[重新继承了一个QDialog类,在里面进行操作]:

pic2

文件1. main.cpp

#include <QtWidgets/QApplication>
#include "dlgShow.h"

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    dlgShow* w = new dlgShow();
    w->show();
    return a.exec();
}

文件2. dlgshow.h


#ifndef DLGSHOW_H
#define DLGSHOW_H

#include <QDialog>
#include <QLabel>
class dlgShow : public QDialog
{
    Q_OBJECT

public:
    dlgShow(QWidget *parent = 0);
    ~dlgShow();

protected slots:
    void openURL(QString url);
};

#endif // DLGSHOW_H

文件3. dlgshow.cpp

#include <QUrl>
#include <QDesktopServices>
#include "dlgshow.h"

dlgShow::dlgShow(QWidget *parent)
    : QDialog(parent)
{   
    setWindowTitle("Dlg:Test Html support");//设置标题
    QString str;
    str = QString("<h1><i>Hello</i> <font color = red>Qt!</font></h1><h2>My CSDN blog: <a href=\"https://blog.csdn.net/humanking7\">https://blog.csdn.net/humanking7 </a></h2>");
    QLabel *lab = new QLabel(str, this);//添加label
    lab->show();
    //绑定超链接与信号槽
    connect(lab, SIGNAL(linkActivated(QString)), this, SLOT(openURL(QString)));

}

void dlgShow::openURL(QString url)
{//槽函数
    //打开对应url的网址
    QDesktopServices::openUrl(QUrl(url));
}

dlgShow::~dlgShow()
{

}

3.支持的标签 Tags

下表列出了Qt富文本引擎支持的Html标签:

TagDescriptionComment
aAnchor or linkSupports the href and name attributes.
addressAddress
bBold
bigLarger font
blockquoteIndented paragraph
bodyDocument bodySupports the bgcolor attribute, which can be a Qt color name or a #RRGGBB color specification.
brLine break
centerCentered paragraph
citeInline citationSame as i.
codeCodeSame as tt.
ddDefinition data
dfnDefinitionSame as i.
divDocument divisionSupports the standard block attributes.
dlDefinition listSupports the standard block attributes.
dtDefinition termSupports the standard block attributes.
emEmphasizedSame as i.
fontFont size, family, and/or colorSupports the following attributes: size, face, and color (Qt color names or #RRGGBB).
h1Level 1 headingSupports the standard block attributes.
h2Level 2 headingSupports the standard block attributes.
h3Level 3 headingSupports the standard block attributes.
h4Level 4 headingSupports the standard block attributes.
h5Level 5 headingSupports the standard block attributes.
h6Level 6 headingSupports the standard block attributes.
headDocument header
hrHorizontal lineSupports the width attribute, which can be specified as an absolute or relative (%) value.
htmlHTML document
iItalic
imgImageSupports the src, source (for Qt 3 compatibility), width, and height attributes.
kbdUser-entered text
metaMeta-informationIf a text encoding is specified using the meta tag, it is picked up by Qt::codecForHtml(). Likewise, if an encoding is specified to QTextDocument::toHtml(), the encoding is stored using a meta tag, for example:
liList item
nobrNon-breakable text
olOrdered listSupports the standard list attributes.
pParagraphLeft-aligned by default. Supports the standard block attributes.
prePreformated text
qtQt rich-text documentSynonym for html. Provided for compatibility with earlier versions of Qt.
sStrikethrough
sampSample codeSame as tt.
smallSmall font
spanGrouped elements
strongStrongSame as b.
subSubscript
supSuperscript
tableTableSupports the following attributes: border, bgcolor (Qt color names or #RRGGBB), cellspacing, cellpadding, width (absolute or relative), and height.
tbodyTable bodyDoes nothing.
tdTable data cellSupports the standard table cell attributes.
tfootTable footerDoes nothing.
thTable header cellSupports the standard table cell attributes.
theadTable headerIf the thead tag is specified, it is used when printing tables that span multiple pages.
titleDocument titleThe value specified using the title tag is available through QTextDocument::metaInformation().
trTable rowSupports the bgcolor attribute, which can be a Qt color name or a #RRGGBB color specification.
ttTypewrite font
uUnderlined
ulUnordered listSupports the standard list attributes.
varVariableSame as i.

4. 对CSS的支持

下表列出了Qt富文本引擎支持的css:

PropertyValuesDescription
background-colorBackground color for elements
background-imageBackground image for elements
colorText foreground color
font-familyFont family name
font-size[ smallmedium
font-style[ normalitalic
font-weight[ normalbold
text-decorationnone[ underline
font[ [ <’font-style’>
text-indentpxFirst line text indentation in pixels
white-spacenormalpre
margin-toppxTop paragraph margin in pixels
margin-bottompxBottom paragraph margin in pixels
margin-leftpxLeft paragraph margin in pixels
margin-rightpxRight paragraph margin in pixels
padding-toppxTop table cell padding in pixels
padding-bottompxBottom table cell padding in pixels
padding-leftpxLeft table cell padding in pixels
padding-rightpxRight table cell padding in pixels
paddingpxShorthand for setting all the padding properties at once.
vertical-alignbaselinesub
border-colorBorder color for text tables.
border-stylenonedotted
background[ <’background-color’>
page-break-before[ autoalways ]
page-break-after[ autoalways ]
float[ leftright
text-transform[ uppercaselowercase ]
font-variantsmall-capsPerform the smallcaps transformation on the text prior to displaying it.
word-spacingpxSpecifies an alternate spacing between each word.

赞赏码New

Qt—QLabel 使用总结 首先我们构造一个 QLabel 对象。通过调用 setText 可以为标签设置文本(Hello World),这时标签就可以正常显示出来了。为了显示更佳的效果,我们可以通过调用 setStyleSheet 来设置样式。 阅读详情

相关推荐

Qt中使用QTableView显示富文本数据源

本文介绍了如何在Qt的QTableView中显示富文本数据源,并以Matlab作为示例进行说明。通过设置富文本项并将其添加到模型中,然后将模型应用到QTableView控件中,可以实现在表格中显示富文本。上述代码创建了一个QTableView对象和一个QStandardItemModel对象,然后通过设置表头和创建富文本项,将富文本数据添加到模型中,最后将模型设置给QTableView控件并显示出来。当程序运行时,将会显示一个表格视图,其中第一行的内容将以富文本形式显示。你可以根据需要自定义富文本的样式。

持续更新 426

Qt textBrowser文本使用超链接跳转窗口

跳转界面为MyInterface。

new1149_的博客 1481

QLabel控件:如何使用以及样式表汇总

在 Qt c++ 的开发过程中,QLabel控件凭借其简单易用和灵活多变的特性,成为了界面开发中不可或缺的组件。本文将详细介绍QLabel控件的基本概念、创建方法、常见用途以及如何利用QSS(Qt Style Sheets)对其进行样式定制。

u011186532的专栏 277

Qt学习笔记(5):QLabel实现外部网页和本地路径超链接

问题分析:相关说明链接有可能是一个网页,也有可能是一个本地文件,所以外部链接分外部网页和本地文件两种实现方式。

weixin_45832156的博客 922

实现QLabel在QT中点击打开URL的功能

为了响应鼠标点击事件,我们需要在我们的QLabel子类中重载函数。下面给出一个简单的示例代码,实现当点击QLabel时,在控制台输出一条消息。Q_OBJECTpublic:protected:// 初始化QLabel,例如设置文本等// 当左键被点击时,输出一条消息到控制台// 不要忘记调用基类的实现在上面的代码中,首先检查了事件是否是鼠标左键点击事件。如果是,我们在控制台输出一条消息,并通过调用基类的确保事件的其他行为(例如焦点处理)仍然可以正常进行。

weixin_35756130的博客 470

Qt基础:QLabel控件之文本编辑与图片展示

QLabel控件用法合集。

u011186532的专栏 883

QTextEdit和QTextDocument(一)

QTextEdit简介: 它可以显示rict text。 这里的rich text不是指microsoft的ricth text,而是用html标签表示的形式。 它通过viewport显示大型文件,而且性能好,可以快速响应用户的操作。 以paragraph和character为基本单位工作。paragraph是格式化的字符串,自动word-wrap以适应容器的大小。一个document由paragraph组成。paragraph可以有自己的alignment属性,paragragh之间由hard li

rea_1121的专栏 2万+

ArcGIS拓扑面错误批量修改

在工作学习中经常会遇到拓扑修改的问题,当数据量巨大的时候会产生拓扑问题 当拓扑错误数量巨大时,人工逐一修改是不现实的,基于此利用gis自带工具箱实现拓扑面类错误的批量修改。 一、.常见拓扑错误的类型: 1面重叠 2空隙(绿色部分) 二、拓扑检查 1新建数据库-----新建数据集—导入数据. 2新建拓扑 3修改拓扑容差及名称 添加拓扑修改规则 完成拓扑检查-查看拓扑错误 三、拓扑批量...

qq_43173805的博客 3万+

qt 富文本 html,Qt对Html富文本支持的控件以及QLabel两种打开超链接的方式

原创文章,欢迎转载。转载请注明:转载自 祥的博客原文链接:https://blog.csdn.net/humanking7/article/details/806858931.说明2.演示2.1. 代码2.2. 关于打开超链接的两种方式说明3.支持的标签 Tags4. 对CSS的支持1.说明Qt的文本窗体部件能够显示富文本,使用HTML4 标记。能够以这种方式显示富文本的窗体控件有: QTextD...

weixin_30843121的博客 1300

银河麒麟V10SP1系统盘瘦身指南:如何制作一个只含必需软件的轻量级安装镜像

本文详细介绍了银河麒麟V10SP1系统盘瘦身的完整流程,从依赖分析到最小化镜像构建,帮助用户创建只含必需软件的轻量级安装镜像。通过智能包筛选、KickStart定制和性能优化,显著减少ISO体积和部署时间,适用于服务器批量部署等场景。

weixin_26765287的博客 408

Qi标准下的充电协议及其记忆技巧

记忆无线充电协议中的。

m0_73991989的博客 1344

Qt 之 QLabel

QLabel提供了一个文本或图像的显示,没有提供用户交互功能。

青春不老,奋斗不止! 6万+

构建面向嵌入式Linux的ARM64交叉编译工具链:从sysroot配置到CMake实战

本文详细介绍了如何构建面向嵌入式Linux的ARM64交叉编译工具链,从sysroot配置到CMake实战。通过分步指导,帮助开发者解决架构不一致问题,提升编译效率,特别适用于树莓派等ARM64设备开发。文章涵盖sysroot机制、环境搭建、CMake配置及常见问题解决方案,是嵌入式开发的实用指南。

weixin_42537142的博客 206

【Qt开发】显示类控件(一)-> QLabel

QLabel是Qt框架中用于显示不可编辑文本和图像的基础控件。作为信息展示的核心组件,它支持纯文本、富文本(HTML)、Markdown等多种格式,并能灵活控制文本对齐、自动换行、缩进和边距等样式。此外,QLabel还可作为图像容器,通过设置scaledContents属性实现图片自适应缩放。其"伙伴"功能允许通过快捷键快速聚焦关联控件,提升操作效率。通过重写resizeEvent函数,可实现QLabel内容随窗口大小动态调整。这些特性使QLabel成为构建用户界面时不可或缺的灵活元素,

枫叶丹4的博客 1953

arcgis密度分析

密度分析 密度分析是指根据输入的要素数据集计算整个区域的数据集状况,从而产生一个连续的密度表面。通过计算密度,将每个采样点的值散布到整个研究区域,并获得输出栅格中每个像元的密度值。在 ArcGIS 中,分布密度的计算方法有点密度分析、线密度分析和核密度分析三种。 1.点密度分析 导入实验数据居民点图层和道路图层 在自定义里勾选空间分析模块Spatial Analyst 点击空间分析工具中密度分析内的点密度分析, 参数设置如下,其中输出像元大小表示输出栅格数据集的像元大小。值越小.

Jasenjane的博客 2万+

Vitis Model Composer闪退?手把手教你用命令行启动Vivado 2021后的System Generator

本文详细解析了Vitis Model Composer闪退问题的根本原因,并提供了命令行启动Vivado 2021后System Generator的完整解决方案。从环境变量配置、组件缺失排查到权限问题处理,手把手教你通过命令行深度排错,并分享高级自动化脚本和系统优化技巧,帮助开发者高效使用Vitis Model Composer与System Generator进行HDL开发。

weixin_26905487的博客 357

如何实现 QLabel 的 Click 事件?Qt 富文本超链接优雅方案

通过void 当前类::onLabelClicked(const QString &escapedLink)// Qt原生接口还原HTML转义字符,得到原始文本// 编写自定义业务逻辑,使用还原后的原始文本qDebug() << "QLabel被点击,原始文本:" << rawText;// 可扩展:弹窗提示、控件更新、数据处理、页面跳转等操作核心基于 QLabel 原生信号实现点击响应,无需子类化、无需处理鼠标事件,Qt5/Qt6 全版本兼容,无额外依赖;富文本拼接采用双参数设计,仅对。

专注echarts开发20年 684

携程机票数据爬取实战:使用 Python 获取携程网机票信息

通过本篇博客,我们详细介绍了如何使用 Python 爬取携程网的机票信息,涉及了静态网页爬取(使用 Requests 和 BeautifulSoup)和动态网页爬取(使用 Selenium)两种方法。通过获取的数据,我们不仅能够进行票价分析,还可以构建更为复杂的预测模型或趋势分析工具。爬虫技术不仅能够帮助我们收集有价值的数据,还能够为商业决策提供数据支持。在实际应用中,我们可以结合更多的分析方法,如自然语言处理、图像处理等,进一步提升数据的价值。

2201_76125261的博客 1672

Qt6.5类库详解:QLabel

1 QLabel主要功能介绍,特点描述和使用说明。 2 QLabel默认风格显示例子。 3 QLabel常用信号、常用属性介绍。 4 QLabel选择文本函数、打开外部链接等功能。 5 QLabel各种风格显示,显示图像等例子。

天恩软件工作室 2206

提升ARM Cortex-M系统性能的关键技术:TCM技术解析与实战指南

TCM技术为ARM Cortex-M处理器提供了宝贵的确定性性能提升手段,特别适合对时序敏感的实时应用。通过合理配置和优化,工程师可以显著提高系统性能、降低中断响应时间并优化功耗。随着嵌入式系统对实时性要求的不断提高,TCM技术将在工业控制、汽车电子、医疗设备等领域发挥更加重要的作用。未来,ARM处理器可能会进一步扩展TCM容量并优化其与其他内存子系统的协同工作方式,为开发者提供更强大的实时性能保障。

1683

全球国家地区城市数据

MySQL全球国家地区城市数据报。。。。。。。。。。。。

Qt之QLabel

简述 QLabel提供了一个文本或图像的显示,没有提供用户交互功能。 一个QLabel能够包括以下随意内容类型: 内容 设置 纯文本 使用setText()设置一个QString 富文本 使用setText()设置一个富文本的QStri...

aoe41606的博客 289

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

《QT 108好类》之6 QLabel类

本文介绍了Qt框架中的QLabel控件类,主要阐述了其功能特性、继承关系及实际应用。QLabel继承自QWidget,支持文本/图像显示、GIF动画、超链接等特性,可设置对齐方式、文本选择和自动换行。通过代码示例展示了QLabel的多种使用场景:作为普通标签、显示富文本/图像/GIF动画、实现超链接、助记符功能等。文章还详细说明了文本和图像的对齐方式设置,并提供了效果展示图。QLabel是Qt中最常用的控件之一,适用于静态内容展示、简单交互等场景。

qq_43550409的博客 1055

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

Qt控件:显示控件

Qt显示控件:QLabel、QCalendarWidget

qingttqing的博客 1034

Qt Widgets模块功能详细说明,基本控件:QLabel(一)

QLabel是常用的轻量级控件,用于显示文本、图像或动画,支持富文本、超链接、自动换行等功能。通过样式表(QSS),可以自定义QLabel的外观,如字体、颜色、背景等。

u013230469的博客 1626

QLabel 的这些小技巧,让你的 UI 变得与众不同!

本文介绍了Qt中QLabel控件的11种高级用法,包括富文本显示、超链接处理、可复制文本、GIF播放、图片缩放等。通过设置TextInteractionFlags、使用QMovie播放动画、事件过滤器实现点击响应等功能,可以扩展QLabel的基础用途。文章还涵盖了边距设置、快捷键聚焦等实用技巧,帮助开发者创建更灵活高效的UI界面。这些技巧使QLabel不仅限于文本显示,还能满足各种交互需求,提升用户体验。

专注于 Qt/C++ 应用开发和机器视觉领域的开源项目分享。期待与您共同进步! 1014

<QT篇>3.QT控件介绍(上)

一共学习了三类控件,后面还有一些控件下一篇继续学习.在我认为,了解控件作用是基础,最重要的是在相应场合能第一时间联想到并且使用它,其次,作为前端设计,我们不仅要实用,还要美观,所以更要学会Qss和布局管理器.

qq_53803232的博客 1419
上一篇: [QT]屏蔽Tab键切换控件焦点
下一篇: [QT]实现Tab键切换控件的两种方式及禁止Tab切换的简单方法
祥知道
博客等级 码龄15年 1148粉丝 147原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值