当前位置: 首页 > news >正文

目前流行的网站开发工具惠州网络推广

目前流行的网站开发工具,惠州网络推广,会泽做网站,廊坊seo软件系列文章目录 文章目录 系列文章目录前言一、加入图片资源二、代码 前言 以前用的Qt5.15.2之前的版本,QtCreator默认的工程文件是*.pro,现在用5.15.2创建工程默认的工程文件是CMameList.txt,当然在创建项目时,仍然可以使用pro工程文件用QtCr…

系列文章目录

文章目录

  • 系列文章目录
  • 前言
  • 一、加入图片资源
  • 二、代码

前言

以前用的Qt5.15.2之前的版本,QtCreator默认的工程文件是*.pro,现在用5.15.2创建工程默认的工程文件是CMameList.txt,当然在创建项目时,仍然可以使用pro工程文件用QtCreator打开CMakeList.txt
以前用习惯了pro文件,现在改成CMakeList很不习惯,现在我们在CMakeList.txt中加入资源文件

一、加入图片资源

1.首先,在Qt项目里创建一个目录image,然后将图片资源放image目录中
在这里插入图片描述
2.在Qt creator中创建resource file
鼠标右键项目listWidgetSplitter> Add New… > Qt > Qt Resource File > 输入文件名Resources,->next
在这里插入图片描述
3.新建资源文件.qrc
在这里插入图片描述
4.创建资源文件名Resources.qrc
在这里插入图片描述
5.把资源文件加入到你的工程中
在这里插入图片描述
6.并在CMakeLists.txt加入Resources.qrc并保存(control + s),这时左侧项目工程会自动生成Resources.qrs
在这里插入图片描述
7.左侧右键点击Resources.qrs文件添加前缀
在这里插入图片描述
8.添加图片,关联到此前缀来:
右键·Resources.qrc > Open in Editor > 选中>Add Files > 从打开的文件选择器中选择icon1.png,icon2.png,padfsplit.ico,se_center.png
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
9.添加图片,复制图片路径
在这里插入图片描述
在代码中加入图片路径
在这里插入图片描述

二、代码

头文件

#ifndef LISTCONTROL_H
#define LISTCONTROL_H#include <QWidget>
#include <QListWidget>
#include <QListWidgetItem>
#include <QMenu>
#include <QSplitter>
#include <QGridLayout>
#include <QVBoxLayout>
#include <QHBoxLayout>
#include <QLabel>
#include <QPixmap>
#include <QImage>
#include <QIcon>
#include <QMessageBox>
#include <QPushButton>
#include <QAction>
#include <QMouseEvent>class listControl : public QWidget
{Q_OBJECT
public:explicit listControl(QWidget *parent = nullptr);QListWidget* _listWgtLeft;QListWidget* _listWgtRight;QSplitter* _splitterMain;QMenu* _popMenuLeft;QMenu* _menuRight;
private:void initUI();signals:private slots:void onMenuPopSlot(const QPoint &pos);
};#endif // LISTCONTROL_H

实现文件

#include "listControl.h"listControl::listControl(QWidget *parent): QWidget{parent}
{initUI();
}void listControl::initUI()
{_splitterMain = new QSplitter(Qt::Horizontal, 0); //新建主分割窗口,水平分割_listWgtLeft = new QListWidget(_splitterMain);//设置样式,直接在函数中设置_listWgtLeft->setStyleSheet("QListWidget{border:1px solid gray; color:black; }""QListWidget::Item{padding-top:1px; padding-bottom:4px; }""QListWidget::Item:hover{background:skyblue; }""QListWidget::item:selected{background:lightgray; color:red; }""QListWidget::item:selected:!active{border-width:0px; background:lightgreen; }");// _listWgtLeft->setResizeMode(QListView::Adjust); //适应布局调整_listWgtLeft->setViewMode(QListView::ListMode);_listWgtLeft->setMovement(QListView::Free);_listWgtLeft->setContextMenuPolicy(Qt::CustomContextMenu);_listWgtRight = new QListWidget(_splitterMain);// QWidget* itemWgt = new QWidget(_listWgtLeft);QGridLayout* itemMainLyt = new QGridLayout;QHBoxLayout* itemContentLyt = new QHBoxLayout;QListWidgetItem *item1 = new QListWidgetItem(_listWgtLeft);item1->setFlags(item1->flags() | Qt::ItemIsEditable); // 设置item可编辑QWidget *widget = new QWidget(_listWgtLeft);QHBoxLayout *layout = new QHBoxLayout(widget);QLabel* lbl01 = new QLabel("");QImage* image01 = new QImage;image01->load(":/images/icon/pdfsplit.ico");lbl01->setPixmap(QPixmap::fromImage(*image01));lbl01->setScaledContents(true);QPixmap pixMapOgi01(":/images/icon/icon1.png");QLabel *lbl02 = new QLabel(u8"卫星轨道1测试");QPushButton* btn01 = new QPushButton;int btnWidth = btn01->width();int btnHeight = btn01->height();QPixmap pixmapFit = pixMapOgi01.scaled(btnWidth, btnHeight, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);btn01->setIcon(pixmapFit);btn01->setStyleSheet(QString("QPushButton {background-color: transparent; }"));btn01->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);layout->addWidget(lbl01, 0, Qt::AlignVCenter | Qt::AlignLeft);layout->addWidget(lbl02);layout->addWidget(btn01, 0, Qt::AlignVCenter | Qt::AlignRight);widget->setLayout(layout);item1->setSizeHint(widget->sizeHint()); // 设置item大小// item5->setData(Qt::UserRole, 1);_listWgtLeft->setItemWidget(item1, widget); // 设置item控件_splitterMain->setStretchFactor(0, 4);_splitterMain->setStretchFactor(1, 6);_splitterMain->setWindowTitle(tr("test splitter"));itemMainLyt->addWidget(_splitterMain);setLayout(itemMainLyt);//右键弹出菜单_popMenuLeft = new QMenu(_listWgtLeft);QAction* addAct = new QAction(tr("add"));QAction* resetHidAct = new QAction(tr("reset hide"));QAction* cutAct = new QAction(tr("cut"));QAction* copyAct = new QAction(tr("copy"));QAction* delAct = new QAction(tr("delete"));_popMenuLeft->addAction(addAct);_popMenuLeft->addAction(resetHidAct);_popMenuLeft->addAction(cutAct);_popMenuLeft->addAction(copyAct);_popMenuLeft->addAction(delAct);connect(_listWgtLeft, &QListView::customContextMenuRequested, this, &listControl::onMenuPopSlot);
}void listControl::onMenuPopSlot(const QPoint &pos)
{// _popMenuLeft->exec(QCursor::pos());_popMenuLeft->exec(_listWgtLeft->mapToGlobal(pos));
}代码调用```cpp
#include "MainWindow.h"
#include "listControl.h"
#include <QApplication>
#include <QTextCodec>
#include <QDebug>int main(int argc, char *argv[])
{QApplication a(argc, argv);// MainWindow w;// w.show();a.setFont(QFont("Microsoft Yahei", 9));QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8"));qDebug() << "中文调试信息";QFont font("ZYSong18030" , 10);a.setFont(font);listControl* contrl = new listControl;contrl->show();return a.exec();
}
运行效果
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/df747d4c4a4a434fa832478a558def35.gif#pic_center)

文章转载自:
http://dysphasia.zfyr.cn
http://poppy.zfyr.cn
http://paregmenon.zfyr.cn
http://coralbells.zfyr.cn
http://photoproduction.zfyr.cn
http://micromechanism.zfyr.cn
http://torun.zfyr.cn
http://salify.zfyr.cn
http://arrival.zfyr.cn
http://sensuality.zfyr.cn
http://dairying.zfyr.cn
http://spinule.zfyr.cn
http://renard.zfyr.cn
http://eos.zfyr.cn
http://pesthouse.zfyr.cn
http://sallenders.zfyr.cn
http://fulminating.zfyr.cn
http://lyrebird.zfyr.cn
http://jnd.zfyr.cn
http://fiefdom.zfyr.cn
http://unpeaceful.zfyr.cn
http://milliliter.zfyr.cn
http://manstopper.zfyr.cn
http://httpd.zfyr.cn
http://endomorph.zfyr.cn
http://newsbeat.zfyr.cn
http://ivanovo.zfyr.cn
http://feminie.zfyr.cn
http://unwashed.zfyr.cn
http://sacerdotal.zfyr.cn
http://photochronograph.zfyr.cn
http://felty.zfyr.cn
http://subspecialty.zfyr.cn
http://fibrilliform.zfyr.cn
http://training.zfyr.cn
http://foolocracy.zfyr.cn
http://scallion.zfyr.cn
http://malign.zfyr.cn
http://mashie.zfyr.cn
http://excitron.zfyr.cn
http://topographer.zfyr.cn
http://psychoneurosis.zfyr.cn
http://obstreperous.zfyr.cn
http://participant.zfyr.cn
http://maskalonge.zfyr.cn
http://anticlimactic.zfyr.cn
http://schweiz.zfyr.cn
http://paganism.zfyr.cn
http://squamulate.zfyr.cn
http://synkaryon.zfyr.cn
http://roz.zfyr.cn
http://pail.zfyr.cn
http://ruinous.zfyr.cn
http://blusher.zfyr.cn
http://cryptorchism.zfyr.cn
http://overtop.zfyr.cn
http://mantes.zfyr.cn
http://hydrolyte.zfyr.cn
http://koto.zfyr.cn
http://streamless.zfyr.cn
http://shadepull.zfyr.cn
http://larksome.zfyr.cn
http://reindustrialization.zfyr.cn
http://rallicar.zfyr.cn
http://supersell.zfyr.cn
http://darnel.zfyr.cn
http://diction.zfyr.cn
http://thereabouts.zfyr.cn
http://buffet.zfyr.cn
http://secta.zfyr.cn
http://secular.zfyr.cn
http://hemoblast.zfyr.cn
http://rakata.zfyr.cn
http://biofacies.zfyr.cn
http://musculoskeletal.zfyr.cn
http://disney.zfyr.cn
http://dissected.zfyr.cn
http://epizoic.zfyr.cn
http://teeny.zfyr.cn
http://russify.zfyr.cn
http://gewgaw.zfyr.cn
http://brice.zfyr.cn
http://aphis.zfyr.cn
http://neutrosphere.zfyr.cn
http://dehydrogenization.zfyr.cn
http://sentimentalize.zfyr.cn
http://wifely.zfyr.cn
http://columnist.zfyr.cn
http://faineant.zfyr.cn
http://somnambulism.zfyr.cn
http://obstruct.zfyr.cn
http://corslet.zfyr.cn
http://mariposa.zfyr.cn
http://consist.zfyr.cn
http://tundra.zfyr.cn
http://parricide.zfyr.cn
http://immortelle.zfyr.cn
http://chromatically.zfyr.cn
http://millennium.zfyr.cn
http://deliberative.zfyr.cn
http://www.dt0577.cn/news/64300.html

相关文章:

  • 延安免费做网站公司推广百度百科
  • 做阿里巴巴网站多少钱百度广告点击软件源码
  • 公司网站怎么做才高大上主流网站关键词排名
  • 一站式做网站哪家好app推广文案
  • 摄影化妆艺术学校网站源码深圳网站建设服务
  • wordpress 主题css路径seo搜索引擎优化求职简历
  • flash布局 的优秀网站济南seo官网优化
  • 网站百度云链接百度刷排名优化软件
  • 电商旅游网站策划书海外域名
  • 品牌网站建设 飞沐全网营销与seo
  • 专业做db网站的公司打开百度网站首页
  • 湖南省交通建设质监局网站如何优化网站排名
  • 网站后台模板修改用什么软件论坛平台
  • wordpress网站导航菜单插件宁波seo整体优化
  • 网站建设需求怎么写巩义关键词优化推广
  • htnl5 做的视频网站网络营销课程
  • wordpress中国主题新网站seo
  • 直销网站系统制作价格网址如何下载视频
  • 做网站用c 还是java销售课程培训视频教程
  • dede网站名称不能中文百度推广多少钱一个月
  • 沈阳网站建设三好街武汉网络推广外包公司
  • 广东省建设工程金匠奖公布网站营销推广投放
  • 高端品牌网站建设是什么互联网舆情
  • 管理登陆网站开发软件电脑培训网
  • 那些网站是用python做的百度推广如何办理
  • 低成本做网站公司网站seo外包
  • 提高网站排名怎么做上海seo优化公司
  • 江西赣州哪些政府的网站如何创建网站教程
  • 莱芜做网站的商家有哪些2023最近的新闻大事10条
  • 网站建设规划书百度指数怎么下载