feat: QListWidget and QToolButton

QListWidget(列表控件) and QToolButton(工具按钮) 的介绍和使用
This commit is contained in:
touwoyimuli 2019-09-01 23:36:59 +08:00
parent 318e9cb6d3
commit e880c851c6
14 changed files with 822 additions and 78 deletions

View File

@ -1,14 +1,216 @@
#include "ExQListWidget.h" #include "ExQListWidget.h"
#include "ui_ExQListWidget.h" #include "ui_ExQListWidget.h"
#include <QDateTime>
ExQListWidget::ExQListWidget(QWidget *parent) : ExQListWidget::ExQListWidget(QWidget *parent) :
QMainWindow(parent), QMainWindow(parent),
ui(new Ui::ExQListWidget) ui(new Ui::ExQListWidget)
{ {
ui->setupUi(this); ui->setupUi(this);
setWindowTitle(QObject::tr("QListWidget和QToolButton用法"));
setCentralWidget(ui->splitter); //将QSplitter分割填充满整个分割区 分别选中左右控件然后鼠标右键Lay out -> Horizon ...
setActionForToolBtn(); //左侧全部按钮 + 右侧三个按钮关联action
creatorPopMenu(); //右侧一个按钮 + 顶部ToolBar两个按钮的创建
ui->listWidget->setContextMenuPolicy(Qt::CustomContextMenu); //设置QListWidget支持右键菜单,这句话一定要有
} }
ExQListWidget::~ExQListWidget() ExQListWidget::~ExQListWidget()
{ {
delete ui; delete ui;
} }
//action控件的槽函数+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//actListInit初始化ListWidget的列表项listWidget
void ExQListWidget::on_actListInit_triggered()
{
QListWidgetItem* item; //每一行都是一个QListWidgetItem
QIcon icon;
icon.addFile(":/images/github.png");
bool chk = ui->checkBox->isChecked(); //是否可编辑
ui->listWidget->clear();
for (int i = 0; i < 13; i++) {
item = new QListWidgetItem();//(ui->listWidget); //创建一个item
item->setText(QString("初始化 第%1个项item").arg(i)); //设置文字
item->setIcon(icon); //设置icon图标
item->setCheckState(Qt::Unchecked); //设置选中方式
if (chk) //可编辑
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
else
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
ui->listWidget->addItem(item); //添加项item到listWidget里面
}
}
//actInsert在ListWidget的列表项中插入一个项item
void ExQListWidget::on_actInsert_triggered()
{
QListWidgetItem* item; //每一行都是一个QListWidgetItem
QIcon icon;
icon.addFile(":/images/gril.png");
bool chk = ui->checkBox->isChecked(); //是否可编辑
item = new QListWidgetItem(); //创建一个item
item->setText(QString("插入一个项item: " + QDateTime::currentDateTime().toString("yyyy-mm-dd hh:MM:ss:zzz"))); //设置文字
item->setIcon(icon); //设置icon图标
item->setCheckState(Qt::Unchecked); //设置选中方式
if (chk) //可编辑
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
else
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserCheckable | Qt::ItemIsEnabled);
ui->listWidget->insertItem(ui->listWidget->currentRow(), item); //添加项item到listWidget里面
}
//actClear清空ListWidget的所有列表项
void ExQListWidget::on_actClear_triggered()
{
ui->listWidget->clear();
}
//actDel删除一个指定的ListWidget的列表项
void ExQListWidget::on_actDel_triggered()
{
int row = ui->listWidget->currentRow();
QListWidgetItem* item = ui->listWidget->takeItem(row); //只是移除为row的item并不删除对象
delete item; //手动删除对象
}
//actAdd添加一个指定的ListWidget的列表项
void ExQListWidget::on_actAdd_triggered()
{
QListWidgetItem* item; //每一行都是一个QListWidgetItem
QIcon icon;
icon.addFile(":/images/TREE.png");
bool chk = ui->checkBox->isChecked(); //是否可编辑
item = new QListWidgetItem(); //创建一个item
item->setText(QString("添加一个项item: " + QDateTime::currentDateTime().toString("yyyy-mm-dd hh:MM:ss:zzz"))); //设置文字
item->setIcon(icon); //设置icon图标
item->setCheckState(Qt::Unchecked); //设置选中方式
if (chk) //可编辑
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsUserTristate | Qt::ItemIsEnabled);
else
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsUserTristate | Qt::ItemIsEnabled);
ui->listWidget->addItem(item); //添加项item到listWidget里面
}
//设置全选
void ExQListWidget::on_actSelAll_triggered()
{
int nCount = ui->listWidget->count();
for (int i = 0; i < nCount; i++) {
QListWidgetItem* item = ui->listWidget->item(i);
item->setCheckState(Qt::Checked);
}
}
//设置全不选
void ExQListWidget::on_actSelNone_triggered()
{
int nCount = ui->listWidget->count();
for (int i = 0; i < nCount; i++) {
QListWidgetItem* item = ui->listWidget->item(i);
item->setCheckState(Qt::Unchecked);
}
}
//设置反选
void ExQListWidget::on_actSelInvs_triggered()
{
int nCount = ui->listWidget->count();
for (int i = 0; i < nCount; i++) {
QListWidgetItem* item = ui->listWidget->item(i);
if (item->checkState() == Qt::Checked)
item->setCheckState(Qt::Unchecked);
else
item->setCheckState(Qt::Checked);
}
}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//设置QListWidget的当前item发生变化触发的信号,会在右侧显示出来
void ExQListWidget::on_listWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous)
{
if (current != nullptr) {
if (previous == nullptr)
ui->lineEditRight->setText(QString("当前项:%1 前一项%2").arg(current->text()).arg("不存在"));
else
ui->lineEditRight->setText(QString("当前项:%1 前一项%2").arg(current->text()).arg(previous->text()));
}
}
//左侧五个按钮, 右侧右边三个按钮 进行QToolButton和action 关联
void ExQListWidget::setActionForToolBtn()
{
//左侧,第一页的五个按钮
ui->toolBtnInit->setDefaultAction(ui->actListInit);
ui->toolBtnClear->setDefaultAction(ui->actClear);
ui->toolBtnInsert->setDefaultAction(ui->actInsert);
ui->toolBtnAdd->setDefaultAction(ui->actAdd);
ui->toolBtnDelete->setDefaultAction(ui->actDel);
//右侧 右边的三个按钮
ui->toolBtnSelAll->setDefaultAction(ui->actSelAll);
ui->toolBtnSelNone->setDefaultAction(ui->actSelInvs);
ui->toolBtnSelInvs->setDefaultAction(ui->actSelNone);
}
//ToolBar 添加项选择(带下拉框) 和退出;右侧一个按钮也添加一个项的选择
void ExQListWidget::creatorPopMenu()
{
//创建菜单
QMenu* menu = new QMenu(this); //创建弹出式菜单
menu->addAction(ui->actSelAll);
menu->addAction(ui->actSelInvs);
menu->addAction(ui->actSelNone);
//右侧ListWidget 其上方的toolBtn按钮
//设置toolBtnSelectItem的多个属性PopupMode、ToolButtonStyle等在Design已经设置
ui->toolBtnSelectItem->setDefaultAction(ui->actSelPopMenu); //关联action
ui->toolBtnSelectItem->setMenu(menu); //设置下拉菜单menu
//工具栏QToolBar上面的下拉菜单样式按钮
QToolButton* toolBtn = new QToolButton(this);
toolBtn->setPopupMode(QToolButton::InstantPopup); //下拉式菜单样式属性
toolBtn->setToolButtonStyle(Qt::ToolButtonTextUnderIcon); //设置汉字出现在icon下面
toolBtn->setDefaultAction(ui->actSelPopMenu); //关联action
toolBtn->setMenu(menu); //关联菜单
ui->toolBar->addSeparator(); //添加隔栏
ui->toolBar->addWidget(toolBtn); //添加到工具栏
//添加退出按钮
ui->toolBar->addSeparator();
ui->toolBar->addAction(ui->actExit); //添加退出按钮
}
//鼠标右键自定义快捷菜单
void ExQListWidget::on_listWidget_customContextMenuRequested(const QPoint &pos)
{
qDebug()<<"11111111";
Q_UNUSED(pos)
QMenu* menu = new QMenu(this); //创建菜单
menu->addAction(ui->actListInit);
menu->addAction(ui->actAdd);
menu->addAction(ui->actDel);
menu->addAction(ui->actClear);
menu->addAction(ui->actInsert);
menu->addSeparator();
menu->addAction(ui->actSelAll);
menu->addAction(ui->actSelNone);
menu->addAction(ui->actSelInvs);
menu->exec(QCursor::pos()); //在鼠标光标位置显示右键快捷菜单
delete menu; //手工创建的指针必须手工删除
}

View File

@ -2,6 +2,8 @@
#define EXQLISTWIDGET_H #define EXQLISTWIDGET_H
#include <QMainWindow> #include <QMainWindow>
#include <QListWidgetItem>
#include <QDebug>
namespace Ui { namespace Ui {
class ExQListWidget; class ExQListWidget;
@ -15,6 +17,22 @@ public:
explicit ExQListWidget(QWidget *parent = nullptr); explicit ExQListWidget(QWidget *parent = nullptr);
~ExQListWidget(); ~ExQListWidget();
private slots:
void on_actListInit_triggered(); //初始化ListWidget
void on_actInsert_triggered(); //插入item
void on_actAdd_triggered(); //添加item
void on_actClear_triggered(); //清除所有item
void on_actDel_triggered(); //删除item
void on_actSelAll_triggered(); //选中所有item
void on_actSelNone_triggered(); //全部不选所有的item
void on_actSelInvs_triggered(); //反选已筛选的item
void on_listWidget_currentItemChanged(QListWidgetItem *current, QListWidgetItem *previous); //显示当前item的变动
void on_listWidget_customContextMenuRequested(const QPoint &pos); //ListWidget弹出鼠标右键菜单
private:
void setActionForToolBtn(); //创建cation和toolButton的关联
void creatorPopMenu(); //创建两个单独的弹出式菜单的ToolButton
private: private:
Ui::ExQListWidget *ui; Ui::ExQListWidget *ui;
}; };

View File

@ -1,24 +1,584 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0"> <ui version="4.0">
<class>ExQListWidget</class> <class>ExQListWidget</class>
<widget class="QMainWindow" name="ExQListWidget" > <widget class="QMainWindow" name="ExQListWidget">
<property name="geometry" > <property name="geometry">
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>400</width> <width>730</width>
<height>300</height> <height>436</height>
</rect> </rect>
</property> </property>
<property name="windowTitle" > <property name="windowTitle">
<string>ExQListWidget</string> <string>ExQListWidget</string>
</property> </property>
<widget class="QMenuBar" name="menuBar" /> <widget class="QWidget" name="centralWidget">
<widget class="QToolBar" name="mainToolBar" /> <widget class="QSplitter" name="splitter">
<widget class="QWidget" name="centralWidget" /> <property name="geometry">
<widget class="QStatusBar" name="statusBar" /> <rect>
<x>0</x>
<y>0</y>
<width>731</width>
<height>341</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<widget class="QToolBox" name="toolBox">
<property name="minimumSize">
<size>
<width>140</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>180</width>
<height>16777215</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="pageList">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>180</width>
<height>251</height>
</rect>
</property>
<attribute name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/List.png</normaloff>:/images/List.png</iconset>
</attribute>
<attribute name="label">
<string>QListWidget展示</string>
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
<widget class="QToolButton" name="toolBtnInit">
<property name="minimumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>toolBtnInit</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget> </widget>
<layoutDefault spacing="6" margin="11" /> </item>
<pixmapfunction></pixmapfunction> <item>
<resources/> <widget class="QToolButton" name="toolBtnClear">
<connections/> <property name="minimumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>toolBtnClear</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolBtnInsert">
<property name="minimumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>toolBtnInsert</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolBtnAdd">
<property name="minimumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>toolBtnAdd</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolBtnDelete">
<property name="minimumSize">
<size>
<width>120</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>toolBtnDelete</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageTree">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>180</width>
<height>251</height>
</rect>
</property>
<property name="cursor">
<cursorShape>SizeVerCursor</cursorShape>
</property>
<attribute name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/TREE.png</normaloff>:/images/TREE.png</iconset>
</attribute>
<attribute name="label">
<string>QTreeWidget展示</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_2">
<item row="0" column="0">
<widget class="QGroupBox" name="groupBox">
<property name="title">
<string>GroupBox</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QLabel" name="labLeft">
<property name="text">
<string>此处没有实现任何功能</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditLeft"/>
</item>
<item>
<widget class="QSpinBox" name="spinBoxLeft"/>
</item>
</layout>
</widget>
</item>
<item row="1" column="0">
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
<widget class="QWidget" name="pageTable">
<attribute name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/Table.png</normaloff>:/images/Table.png</iconset>
</attribute>
<attribute name="label">
<string>QTableWidget展示</string>
</attribute>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>10</x>
<y>60</y>
<width>161</width>
<height>91</height>
</rect>
</property>
<property name="text">
<string>此处连布局都没有</string>
</property>
</widget>
</widget>
</widget>
<widget class="QTabWidget" name="tabWidget">
<property name="minimumSize">
<size>
<width>320</width>
<height>0</height>
</size>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="QWidget" name="tabList">
<attribute name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/List.png</normaloff>:/images/List.png</iconset>
</attribute>
<attribute name="title">
<string>QListWidget</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_3">
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
<widget class="QToolButton" name="toolBtnSelectItem">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>tBtnSelectItem</string>
</property>
<property name="popupMode">
<enum>QToolButton::MenuButtonPopup</enum>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextBesideIcon</enum>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolBtnSelAll">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>tBtnSelAll</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolBtnSelNone">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>tBtnSelNone</string>
</property>
</widget>
</item>
<item>
<widget class="QToolButton" name="toolBtnSelInvs">
<property name="minimumSize">
<size>
<width>0</width>
<height>25</height>
</size>
</property>
<property name="text">
<string>tBtnSelInvs</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="1" column="0">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="labCurrItem">
<property name="text">
<string>当前项的变化:</string>
</property>
</widget>
</item>
<item>
<widget class="QLineEdit" name="lineEditRight"/>
</item>
<item>
<widget class="QCheckBox" name="checkBox">
<property name="text">
<string>可编辑</string>
</property>
</widget>
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QListWidget" name="listWidget">
<item>
<property name="text">
<string>this is first item</string>
</property>
<property name="checkState">
<enum>Unchecked</enum>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/github.png</normaloff>:/images/github.png</iconset>
</property>
<property name="flags">
<set>ItemIsSelectable|ItemIsEditable|ItemIsDragEnabled|ItemIsUserCheckable|ItemIsEnabled</set>
</property>
</item>
<item>
<property name="text">
<string>这是第二个项item</string>
</property>
<property name="checkState">
<enum>Unchecked</enum>
</property>
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/gril.png</normaloff>:/images/gril.png</iconset>
</property>
</item>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTree">
<attribute name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/TREE.png</normaloff>:/images/TREE.png</iconset>
</attribute>
<attribute name="title">
<string>QTreeWidget</string>
</attribute>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QPushButton" name="pushButton">
<property name="text">
<string>这里什么都没有,只有一个布局,此页面也没有实现任何功能</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabTable">
<attribute name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/Table.png</normaloff>:/images/Table.png</iconset>
</attribute>
<attribute name="title">
<string>QTableWidget</string>
</attribute>
<widget class="QLabel" name="label">
<property name="geometry">
<rect>
<x>110</x>
<y>120</y>
<width>331</width>
<height>101</height>
</rect>
</property>
<property name="text">
<string>这里什么都没有,连布局都没有</string>
</property>
</widget>
</widget>
</widget>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>730</width>
<height>23</height>
</rect>
</property>
</widget>
<widget class="QStatusBar" name="statusBar"/>
<widget class="QToolBar" name="toolBar">
<property name="windowTitle">
<string>toolBar</string>
</property>
<property name="toolButtonStyle">
<enum>Qt::ToolButtonTextUnderIcon</enum>
</property>
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
<addaction name="actListInit"/>
<addaction name="actClear"/>
<addaction name="actInsert"/>
<addaction name="actAdd"/>
<addaction name="actDel"/>
</widget>
<action name="actListInit">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/init.png</normaloff>:/images/init.png</iconset>
</property>
<property name="text">
<string>初始化</string>
</property>
<property name="toolTip">
<string>初始化列表</string>
</property>
<property name="shortcut">
<string>Ctrl+I</string>
</property>
</action>
<action name="actClear">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/clear.png</normaloff>:/images/clear.png</iconset>
</property>
<property name="text">
<string>清除</string>
</property>
<property name="toolTip">
<string>清除列表</string>
</property>
<property name="shortcut">
<string>Alt+C</string>
</property>
</action>
<action name="actInsert">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/insert.png</normaloff>:/images/insert.png</iconset>
</property>
<property name="text">
<string>插入</string>
</property>
<property name="toolTip">
<string>插入项</string>
</property>
<property name="shortcut">
<string>Alt+I</string>
</property>
</action>
<action name="actAdd">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/add.png</normaloff>:/images/add.png</iconset>
</property>
<property name="text">
<string>添加</string>
</property>
<property name="toolTip">
<string>添加项</string>
</property>
<property name="shortcut">
<string>Alt+A</string>
</property>
</action>
<action name="actDel">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/delete.png</normaloff>:/images/delete.png</iconset>
</property>
<property name="text">
<string>删除</string>
</property>
<property name="toolTip">
<string>删除当前项目</string>
</property>
<property name="shortcut">
<string>Ctrl+D</string>
</property>
</action>
<action name="actSelAll">
<property name="text">
<string>全选</string>
</property>
<property name="toolTip">
<string>选择全部</string>
</property>
<property name="shortcut">
<string>Ctrl+A</string>
</property>
</action>
<action name="actSelNone">
<property name="text">
<string>全不选</string>
</property>
<property name="toolTip">
<string>全部不选中</string>
</property>
</action>
<action name="actSelInvs">
<property name="text">
<string>反选</string>
</property>
<property name="toolTip">
<string>选择相反的部分</string>
</property>
</action>
<action name="actSelPopMenu">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/menu.png</normaloff>:/images/menu.png</iconset>
</property>
<property name="text">
<string>选项</string>
</property>
<property name="toolTip">
<string>多种选择方式</string>
</property>
</action>
<action name="actExit">
<property name="icon">
<iconset resource="resources.qrc">
<normaloff>:/images/exit.png</normaloff>:/images/exit.png</iconset>
</property>
<property name="text">
<string>退出</string>
</property>
<property name="toolTip">
<string>退出程序</string>
</property>
<property name="shortcut">
<string>Ctrl+0</string>
</property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="resources.qrc"/>
</resources>
<connections>
<connection>
<sender>actSelPopMenu</sender>
<signal>triggered()</signal>
<receiver>actSelInvs</receiver>
<slot>trigger()</slot>
<hints>
<hint type="sourcelabel">
<x>-1</x>
<y>-1</y>
</hint>
<hint type="destinationlabel">
<x>363</x>
<y>212</y>
</hint>
</hints>
</connection>
</connections>
</ui> </ui>

View File

@ -1,14 +0,0 @@
#include "Examples.h"
#include "ui_Examples.h"
Examples::Examples(QWidget *parent) :
QWidget(parent),
ui(new Ui::Examples)
{
ui->setupUi(this);
}
Examples::~Examples()
{
delete ui;
}

View File

@ -1,22 +0,0 @@
#ifndef EXAMPLES_H
#define EXAMPLES_H
#include <QWidget>
namespace Ui {
class Examples;
}
class Examples : public QWidget
{
Q_OBJECT
public:
explicit Examples(QWidget *parent = nullptr);
~Examples();
private:
Ui::Examples *ui;
};
#endif // EXAMPLES_H

View File

@ -1,20 +0,0 @@
<ui version="4.0">
<class>Examples</class>
<widget class="QWidget" name="Examples" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>400</width>
<height>300</height>
</rect>
</property>
<property name="windowTitle" >
<string>Examples</string>
</property>
</widget>
<layoutDefault spacing="6" margin="11" />
<pixmapfunction></pixmapfunction>
<resources/>
<connections/>
</ui>

View File

@ -1,6 +1,6 @@
#------------------------------------------------- #-------------------------------------------------
# #
# Project created by QtCreator 2019-08-30T19:36:43 # Project created by QtCreator 2019-08-30T19:39:47
# #
#------------------------------------------------- #-------------------------------------------------
@ -8,7 +8,7 @@ QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = QtQlistWidgetEx TARGET = QtQListWidgetEx
TEMPLATE = app TEMPLATE = app
# The following define makes your compiler emit warnings if you use # The following define makes your compiler emit warnings if you use
@ -26,15 +26,21 @@ CONFIG += c++11
SOURCES += \ SOURCES += \
main.cpp \ main.cpp \
Examples.cpp ExQListWidget.cpp
HEADERS += \ HEADERS += \
Examples.h ExQListWidget.h
FORMS += \ FORMS += \
Examples.ui ExQListWidget.ui
RC_ICONS += qt.ico
# Default rules for deployment. # Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target !isEmpty(target.path): INSTALLS += target
RESOURCES += \
resources.qrc

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 940 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 401 B

View File

@ -1,10 +1,10 @@
#include "Examples.h" #include "ExQListWidget.h"
#include <QApplication> #include <QApplication>
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
QApplication a(argc, argv); QApplication a(argc, argv);
Examples w; ExQListWidget w;
w.show(); w.show();
return a.exec(); return a.exec();

BIN
QtQlistWidgetEx/qt.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@ -1,2 +1,16 @@
<!DOCTYPE RCC> <RCC>
<RCC version="1.0"/> <qresource prefix="/">
<file>images/add.png</file>
<file>images/clear.png</file>
<file>images/delete.png</file>
<file>images/init.png</file>
<file>images/insert.png</file>
<file>images/List.png</file>
<file>images/Table.png</file>
<file>images/TREE.png</file>
<file>images/github.png</file>
<file>images/gril.png</file>
<file>images/exit.png</file>
<file>images/menu.png</file>
</qresource>
</RCC>