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

校园网站建设需求分析小本本教你做网站

校园网站建设需求分析,小本本教你做网站,网上申请开办公司流程,怎样打开网站1.窗口标题 this->setWindowTitle("to my lovely girl"); 2.设置窗口透明度 正常为1.0,透明为0.0 this->setWindowOpacity(0.0); 啥也没有 3.设置图片路径 1.绝对路径(极少用) 2.相对路径:使用方法 QIcon ic…
1.窗口标题
this->setWindowTitle("to my lovely girl");

2.设置窗口透明度

正常为1.0,透明为0.0

 this->setWindowOpacity(0.0);

 

啥也没有

3.设置图片路径

1.绝对路径(极少用)

2.相对路径:使用方法

 QIcon icon("D:/project/p2.jpg")

 

 

3.资源文件法

 

 

会发现左侧文件栏出现资源文件选项,在路径里面找到对应qrc文件后,在同级目录或者子目录下放置图片,就可以通过资源文件前缀(创建时有显著表示提示创建)+文件名称调用了

4.qrc机制

就是3中的资源文件法,qt使用的qrc机制主要解决两个问题,第一个是文件所在路径在用户机器上存在,第二个是文件不会被用户误删或修改,但是会存在一个问题,就是资源文件不能过大

qrc文件的特点:

        1.XML格式的资源文件

        2.用 XML 记录硬盘上的文件和对应的随意指定的资源名称,应用程序通过资源名称来访问这些资源

        3.在 Qt 开发中,可以通过将资源文件添加到项目中来方便地访问和管理这些资源,这些资源文件可以位于 qrc 文件所在目录的同级或其子目录下

        4.在构建程序的过程中,Qt 会把资源文件的二进制数据转成 cpp 代码,编译到 exe 中,从而使依赖的资源变得 “路径无关”

 5.ToolTips

 就是鼠标放在某个按钮上会在一定时间显示一段话,可以使用两个函数来控制

    q1->setToolTip("please");q1->setToolTipDuration(3000);

下面时间是毫秒

 

6. 控件状态与控制

一个控件肯定有能使用和不能使用,而使用对象可以是鼠标或者是按键如Tab,这里演示用按钮控制另一个按钮是否可以被鼠标选中(q是一个按钮)

void MainWindow::changecq()
{bool able=q->isEnabled();if(able){q->setEnabled(false);}else{q->setEnabled(true);}}

 

 7.自主设置鼠标图标

在按下某些按钮后可以设置鼠标变换图标,比如经典的蓝圈,现在介绍一种自定义图片的方法

  QPixmap qp("D:/project/p1.jpg");
QPixmap dp = qp.scaled(10, 10, Qt::KeepAspectRatio);QCursor cd(dp, dp.width()/2, dp.height()/2);QApplication::setOverrideCursor(cd);

找到图片路径,设置图片大小,设置热点(类似鼠标箭头),再使用,就会发现我的鼠标箭头变成了图片

8.颜色控制

白天模式与黑夜模式的颜色设置

void MainWindow::turnon()
{this->centralWidget()->setStyleSheet("background-color:white");this->setStyleSheet("QPushButton { background-color:black; color: white; }");}
void MainWindow::turnoff()
{this->centralWidget()->setStyleSheet("background-color:black");this->setStyleSheet("QPushButton { background-color:white; color: black; }");
}

centralWidget()设置主窗口颜色,然后再使用以上语句对按钮颜色和字体颜色进行选择

 

 

 颜色方面,

rgb(255, 0, 0) 或者 #FF0000 或者 #F00 表示纯红色。
rgb(0, 255, 0) 或者 #00FF00 或者 #0F0 表示纯绿色。
rgb(0, 0, 255) 或者 #0000FF 或者 #00F 表示纯蓝色。
rgb(255, 255, 255) 或者 #FFFFFF 或者 #FFF 表示纯白色。
rgb(0, 0, 0) 或者 #000000 或者 #000 表示纯黑色。

9.加入演示后的表白窗口的完整代码

pro

QT       += core gui
QMAKE_PROJECT_DEPTH = 0greaterThan(QT_MAJOR_VERSION, 4): QT += widgetsCONFIG += c++17# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0SOURCES += \main.cpp \mainwindow.cppHEADERS += \mainwindow.hFORMS += \mainwindow.ui# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += targetRESOURCES += \mysource.qrc

头文件

#ifndef MAINWINDOW_H
#define MAINWINDOW_H#include <QMainWindow>
#include<QPushButton>
#include<ctime>
QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACEclass MainWindow : public QMainWindow
{Q_OBJECTpublic:MainWindow(QWidget *parent = nullptr);~MainWindow();
public slots:void changeq1();void changeq2();void changecq();void turnon();void turnoff();private:Ui::MainWindow *ui;
public:QPushButton *q1;QPushButton*q2;QPushButton*q;QPushButton*cq;QPushButton*light;QPushButton*dark;
};
#endif // MAINWINDOW_H

main.h

#include "mainwindow.h"#include <QApplication>
#include<QObject>
#include<QPushButton>
#include<QDir>
int main(int argc, char *argv[])
{QApplication a(argc, argv);MainWindow w;w.show();qDebug()<<QCoreApplication::applicationDirPath()<<'\n';qDebug()<<QDir::currentPath();return a.exec();
}

源文件

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QPixmap>
MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);this->setWindowTitle("to my lovely girl");this->setWindowOpacity(1.0);QIcon icon(":/new/p3.jpg");//("D:/project/p2.jpg");this->setWindowIcon(icon);q1=new QPushButton("yes",this);q1->setGeometry(300,200,50,50);q1->setToolTip("please");q1->setToolTipDuration(3000);q2=new QPushButton("no",this);q2->setGeometry(450,200,50,50);q=new QPushButton("do you love me?",this);q->setGeometry(300,300,200,100);q->setEnabled(false);cq=new QPushButton("control the button",this);cq->setGeometry(100,300,100,50);std::srand(std::time(nullptr));light=new QPushButton("light",this);light->setGeometry(375,50,50,50);dark=new QPushButton("dark",this);dark->setGeometry(375,100,50,50);connect(q1, &QPushButton::clicked, this, &MainWindow::changeq1);connect(q2, &QPushButton::clicked, this, &MainWindow::changeq2);connect(cq,&QPushButton::clicked,this,&MainWindow::changecq);connect(light,&QPushButton::clicked, this, &MainWindow::turnon);connect(dark,&QPushButton::clicked, this, &MainWindow::turnoff);
}void MainWindow::changeq1()
{QPixmap qp("D:/project/p1.jpg");
QPixmap dp = qp.scaled(10, 10, Qt::KeepAspectRatio);QCursor cd(dp, dp.width()/2, dp.height()/2);QApplication::setOverrideCursor(cd);QPushButton* q3=new QPushButton("have a dinner?",this);q3->setGeometry(250,500,300,100);q3->show();connect(q3, &QPushButton::clicked, this, &MainWindow::close);
}
void MainWindow:: changeq2()
{int x=std::rand()%100;int y=std::rand()%100;q2->setGeometry(x,y,50,50);
}
void MainWindow::changecq()
{bool able=q->isEnabled();if(able){q->setEnabled(false);}else{q->setEnabled(true);}}
void MainWindow::turnon()
{this->centralWidget()->setStyleSheet("background-color:white");this->setStyleSheet("QPushButton { background-color:black; color: white; }");}
void MainWindow::turnoff()
{this->centralWidget()->setStyleSheet("background-color:black");this->setStyleSheet("QPushButton { background-color:white; color: black; }");
}
MainWindow::~MainWindow()
{delete ui;
}


文章转载自:

http://Eg0V4xH8.Lkkgq.cn
http://ds7gD9qi.Lkkgq.cn
http://LmUDgnPO.Lkkgq.cn
http://8fCicemF.Lkkgq.cn
http://p2VdcZXz.Lkkgq.cn
http://ARw5TBYq.Lkkgq.cn
http://xYcs5Pui.Lkkgq.cn
http://TQKBllwo.Lkkgq.cn
http://wH4FGPcu.Lkkgq.cn
http://p54s35ZM.Lkkgq.cn
http://Vq8PAfLD.Lkkgq.cn
http://UXhROIf0.Lkkgq.cn
http://2yvPqEFJ.Lkkgq.cn
http://GZ6Y9EvN.Lkkgq.cn
http://bfe93cJQ.Lkkgq.cn
http://TgMlPk9y.Lkkgq.cn
http://xTC4hZDn.Lkkgq.cn
http://q28gqbW1.Lkkgq.cn
http://Qpj39gH3.Lkkgq.cn
http://i22oxlLW.Lkkgq.cn
http://6jV2yGLK.Lkkgq.cn
http://aQxgrFso.Lkkgq.cn
http://Vom4BX1b.Lkkgq.cn
http://yNbN4r81.Lkkgq.cn
http://pSwcKbIC.Lkkgq.cn
http://8v94zMzn.Lkkgq.cn
http://pYDPQwAW.Lkkgq.cn
http://l7mYWHpc.Lkkgq.cn
http://DdUx50JL.Lkkgq.cn
http://FLtBn38i.Lkkgq.cn
http://www.dtcms.com/wzjs/606601.html

相关文章:

  • 免费行情网站app大全电商网站订烟平台官网
  • php企业网站模板下载建筑设计公司logo
  • 福田做棋牌网站建设哪家技术好做微信平台图片网站
  • 怎么做淘宝联盟的推广网站提高审美的网站推荐
  • 网站的运营模式不允许访问网站
  • 宠物出售的网站怎么做网页制作方案策划
  • 做年会的网站现在网站一般做多大的
  • 阿坝网站设计属于c2c网站的有哪几个
  • 上海有制作网站的电话吗海口网站建设的开发方案
  • 网站建设与规划试卷兼职做网站安全么
  • vps网站压缩权威发布图片
  • 有哪些做简历的网站开展我国电子网站建设
  • 广州网站建设哪家公司好免费推广的软件
  • 网站建设 三牛xps13适合网站开发吗
  • 地方门户类网站建设项目查询
  • 中国投诉网站做袜子机器多少钱一台网页动态设计怎么做
  • docker 做网站网站介绍模板
  • 网站建设的具体代码新余网站开发
  • 神秘网站短视频营销名词解释
  • 网站建设销售话凡科网是干嘛用的
  • 如何选择小程序定制公司连云港专业网站优化
  • 苏州标志设计公司固原地网站seo
  • 房产网站模板旅游网络营销的优势
  • 专注郑州网站建设泉州网站seo外包公司
  • 有哪些网站做国外生意的昆明云南微网站搭建哪家好
  • 网站托管服务适合wordpress多站显示不正常
  • 商城型移动端网站开发多少钱中国建设银行总行官方网站
  • 都匀经济开发区建设局网站高端科技网站建设
  • 物流网站建设的小结哈尔滨市城乡和建设局网站
  • 龙口网站建设公司哪家好宁波关键词网站排名