Qt5.14封装 QTextEdit可现实行号和列号

概述

  • 开发操作系统: win11
  • Qt版本: 5.14
  • 封装之初心, 用于显示网络和串口收到的源码数据, 十六进制显示,每一帧显示一行

功能

  • 可显示行号和列号
  • 可指定列数与行数
  • 显示滚动条

界面组成

  • 全部由QTextEdit组成, 共四个。 其中,左上角的 没有用到。 仅仅起到了占位的作用。 见下图

显示范例

  • 下面用于显示源码范例

用法

  • 直接调用append 函数即可

控件组成

  • UI文件,数量:1个
  • 头文件, 数量: 1个
  • 源文件, 数量: 1个

UI文件源码

  • ui文件名: ListCtrlEx.ui
  • 文件源码:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
 <class>ListCtrlExClass</class>
 <widget class="QWidget" name="ListCtrlExClass">
  <property name="geometry">
   <rect>
    <x>0</x>
    <y>0</y>
    <width>410</width>
    <height>197</height>
   </rect>
  </property>
  <property name="windowTitle">
   <string>ListCtrlEx</string>
  </property>
  <property name="styleSheet">
   <string notr="true">font: 10pt &quot;Consolas&quot;;</string>
  </property>
  <layout class="QHBoxLayout" name="horizontalLayout" stretch="1,20">
   <property name="spacing">
    <number>0</number>
   </property>
   <item>
    <layout class="QVBoxLayout" name="verticalLayout">
     <property name="spacing">
      <number>0</number>
     </property>
     <item>
      <widget class="QTextEdit" name="te_header_2">
       <property name="enabled">
        <bool>false</bool>
       </property>
       <property name="sizePolicy">
        <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
         <horstretch>0</horstretch>
         <verstretch>0</verstretch>
        </sizepolicy>
       </property>
       <property name="maximumSize">
        <size>
         <width>60</width>
         <height>20</height>
        </size>
       </property>
       <property name="styleSheet">
        <string notr="true"/>
       </property>
       <property name="verticalScrollBarPolicy">
        <enum>Qt::ScrollBarAlwaysOff</enum>
       </property>
       <property name="horizontalScrollBarPolicy">
        <enum>Qt::ScrollBarAlwaysOff</enum>
       </property>
       <property name="readOnly">
        <bool>true</bool>
       </property>
      </widget>
     </item>
     <item>
      <widget class="QTextEdit" name="te_line_id">
       <property name="enabled">
        <bool>false</bool>
       </property>
       <property name="sizePolicy">
        <sizepolicy hsizetype="Fixed" vsizetype="Expanding">
    
  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值