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

百科网站怎么做我为什么不建议年轻人做销售

百科网站怎么做,我为什么不建议年轻人做销售,网络平台开发,电子请帖免费制作app⼯具栏 ⼯具栏是应⽤程序中集成各种功能实现快捷键使⽤的⼀个区域。可以有多个,也可以没有,它并不是应⽤程序中必须存在的组件。它是⼀个可移动的组件,它的元素可以是各种窗⼝组件,它的元素通常以图标按钮的⽅式存在。如下图为⼯…

⼯具栏

⼯具栏是应⽤程序中集成各种功能实现快捷键使⽤的⼀个区域。可以有多个,也可以没有,它并不是应⽤程序中必须存在的组件。它是⼀个可移动的组件,它的元素可以是各种窗⼝组件,它的元素通常以图标按钮的⽅式存在。如下图为⼯具栏的⽰意图:
![[Pasted image 20250423103543.png]]

创建⼯具栏

调⽤QMainWindow类的addToolBar()函数来创建⼯具栏,每增加⼀个⼯具栏都需要调⽤⼀次该函数。
如添加两个⼯具栏:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QDebug>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//工具栏手动创建QToolBar* toolBar = new QToolBar();this->addToolBar(toolBar);QAction* action1 = new QAction("保存");toolBar->addAction(action1);QAction* action2 = new QAction("打开");toolBar->addAction(action2);connect(action1, &QAction::triggered, this, &MainWindow::handle1);connect(action2, &QAction::triggered, this, &MainWindow::handle2);
}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::handle1()
{qDebug() << "handle1";
}void MainWindow::handle2()
{qDebug() << "handle2";
}

使用QToolBar表示工具栏对象
一个窗口可以有多个工具栏,也可以没有
工具栏往往也可以手动移动位置
添加菜单栏,使用的是setMenuBar
添加工具栏,使用的是addToolBar
菜单栏只能有一个.重复设置,新的替换旧的(set就包含了"替换")
工具栏,可以有多个.重复设置,就会出现多个工具栏不包含“替换”
![[Pasted image 20250423124419.png]]

    action1->setIcon(QIcon(":/save.png"));action2->setIcon(QIcon(":/new.png"));

QAction如果出现在工具栏上,也会产生图标覆盖文本这样的情况
会以toolTip的方式来存在
鼠标悬停上去的时候,就会显示出一段提示信息
另外也可以手动设置这里的toolTip
![[Pasted image 20250423124838.png]]

    action1->setToolTip("点击这里保存文件");

![[Pasted image 20250423125513.png]]

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>
#include <QDebug>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//创建菜单栏QMenuBar* menuBar = this->menuBar();this->setMenuBar(menuBar);//创建菜单QMenu* menu = new QMenu("文件");menuBar->addMenu(menu);//工具栏手动创建QToolBar* toolBar = new QToolBar();this->addToolBar(toolBar);QAction* action1 = new QAction("保存");QAction* action2 = new QAction("打开");action1->setToolTip("点击这里保存文件");action1->setIcon(QIcon(":/save.png"));action2->setIcon(QIcon(":/new.png"));//菜单项放在工具栏中toolBar->addAction(action1);toolBar->addAction(action2);//菜单项放在菜单中menu->addAction(action1);menu->addAction(action2);connect(action1, &QAction::triggered, this, &MainWindow::handle1);connect(action2, &QAction::triggered, this, &MainWindow::handle2);
}MainWindow::~MainWindow()
{delete ui;
}void MainWindow::handle1()
{qDebug() << "handle1";
}void MainWindow::handle2()
{qDebug() << "handle2";
}

![[Pasted image 20250423130419.png]]

工具栏往往也是和菜单栏搭配使用的
工具栏中的QAction也可以出现在菜单中
如果一个QAction既是QMenu的子元素,又是QToolBar的子元素,释放的时候,是否会重复delete
只会释放一次,不会重复delete

设置停靠位置

⼯具栏停靠位置的设置有两种⽅式。⼀种是在创建⼯具栏的同时指定停靠的位置,另⼀种是通过QToolBar类提供的setAllowedAreas()函数来设置。
⽅式⼀:创建⼯具栏的同时指定其停靠的位置。
在创建⼯具栏的同时,也可以设置⼯具栏的位置,其默认位置是在窗⼝的最上⾯;如上述代码,默认在最上⾯显⽰。⼯具栏允许停靠的区域由QToolBar类提供的allowAreas()函数决定,其中可以设置的位置包括:

  1. 可以设置工具栏出现的初始位置(上下左右…)
  2. 可以设置工具栏允许停放到哪些边缘
  3. 可以设置工具栏是否允许浮动
  4. 可以设置工具栏是否可以移动
  • Qt::LeftToolBarArea:停靠在左侧
  • Qt::RightToolBarArea:停靠在右侧
  • Qt::TopToolBarArea:停靠在顶部
  • Qt::BottomToolBarArea:停靠在底部
  • Qt::AllToolBarAreas:以上四个位置都可停靠
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);QToolBar* toolBar1 = new QToolBar();QToolBar* toolBar2 = new QToolBar();this->addToolBar(toolBar1);this->addToolBar(toolBar2);QAction* action1 = new QAction("动作1");QAction* action2 = new QAction("动作2");QAction* action3 = new QAction("动作3");QAction* action4 = new QAction("动作4");toolBar1->addAction(action1);toolBar1->addAction(action2);toolBar2->addAction(action3);toolBar2->addAction(action4);
}

![[Pasted image 20250423132806.png]]

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QToolBar>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);QToolBar* toolBar1 = new QToolBar();QToolBar* toolBar2 = new QToolBar();this->addToolBar(toolBar1);this->addToolBar(Qt::LeftToolBarArea, toolBar2);QAction* action1 = new QAction("动作1");QAction* action2 = new QAction("动作2");QAction* action3 = new QAction("动作3");QAction* action4 = new QAction("动作4");toolBar1->addAction(action1);toolBar1->addAction(action2);toolBar2->addAction(action3);toolBar2->addAction(action4);
}

![[Pasted image 20250423134326.png]]

⽅式⼆:使⽤QToolBar类提供的setAllowedAreas()函数设置停靠位置。如下⽰例:

    QToolBar* toolBar1 = new QToolBar();QToolBar* toolBar2 = new QToolBar();this->addToolBar(toolBar1);this->addToolBar(Qt::LeftToolBarArea, toolBar2);//允许在左右侧停靠toolBar2->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);

在创建⼯具栏的同时指定其停靠的位置,指的是程序运⾏时⼯具栏默认所在的位置;⽽使⽤setAllowedAreas()函数设置停靠位置,指的是⼯具栏允许其所能停靠的位置。

设置浮动属性

⼯具栏的浮动属性可以通过 QToolBar类 提供的setFloatable()函数 来设置。setFloatable()函数原型为:
void setFloatable(bool floatable)
参数:
true:浮动
false:不浮动

    QToolBar* toolBar1 = new QToolBar();QToolBar* toolBar2 = new QToolBar();this->addToolBar(toolBar1);this->addToolBar(Qt::LeftToolBarArea, toolBar2);//只允许停靠在左侧或者右侧toolBar2->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);//设置不允许浮动toolBar2->setFloatable(false);
设置移动属性

设置⼯具栏的移动属性可以通过QToolBar类提供的setMovable()函数来设置。setMovable()函数原型为:
void setMovable(bool movable)
参数:
true:移动
false:不移动
说明:若设置⼯具栏为不移动状态,则设置其停靠位置的操作就不会⽣效,所以设置⼯具栏的移动属性类似于总开关的效果

    QToolBar* toolBar1 = new QToolBar();QToolBar* toolBar2 = new QToolBar();this->addToolBar(toolBar1);this->addToolBar(Qt::LeftToolBarArea, toolBar2);//只允许停靠在左侧或者右侧toolBar2->setAllowedAreas(Qt::LeftToolBarArea | Qt::RightToolBarArea);//设置不允许浮动toolBar2->setFloatable(false);//设置不允许移动toolBar2->setMovable(false);

![[Pasted image 20250423135906.png]]

综合⽰例

![[Pasted image 20250423140033.png]]

状态栏

状态栏是应⽤程序中输出简要信息的区域。⼀般位于主窗⼝的最底部,⼀个窗⼝中最多只能有⼀个状态栏。在Qt中,状态栏是通过QStatusBar类来实现的。在状态栏中可以显⽰的消息类型有:

  • 实时消息:如当前程序状态
  • 永久消息:如程序版本号,机构名称
  • 进度消息:如进度条提⽰,百分百提⽰
状态栏的创建

状态栏的创建是通过QMainWindow类提供的statusBar()函数来创建;⽰例如下:

#include "mainwindow.h"
#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//存在就获取,不存在就创建QStatusBar* statusBar = this->statusBar();//如果状态栏没有被创建,这样的设置是必要的//如果状态栏已经在窗口中存在,这样设置的意义不大,但也没有副作用,仍然保留this->setStatusBar(statusBar);
}
在状态栏中显⽰实时消息

在状态栏中显⽰实时消息是通过showMessage()函数来实现,⽰例如下:

    //显示一个临时的信息statusBar->showMessage("这是一个状态消息", 3000);

![[Pasted image 20250423140917.png]]

3秒之后,消息自动消失
通过showMessage可以在状态栏中显示一个文本.
此时这个文本存在的时间可以自定义.
timeout参数是一个单位为ms的时间,如果timeout为0(不填),消息就会持久存在

在状态栏中显⽰永久消息

在状态栏中可以显⽰永久消息,此处的永久消息是通过标签来显⽰的;⽰例如下:
![[Pasted image 20250423141848.png]]

addWidget从左往右添加.
addPermanentWidget从右往左添加.

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//存在就获取,不存在就创建QStatusBar* statusBar = this->statusBar();//如果状态栏没有被创建,这样的设置是必要的//如果状态栏已经在窗口中存在,这样设置的意义不大,但也没有副作用,仍然保留this->setStatusBar(statusBar);//给状态栏添加子控件QLabel* label = new QLabel("这是一个QLabel");statusBar->addWidget(label);
}

![[Pasted image 20250423142045.png]]

    //给状态栏添加子控件QLabel* label = new QLabel("这是一个QLabel");statusBar->addWidget(label);QLabel* label2 = new QLabel("这是另一个QLabel");statusBar->addPermanentWidget(label2);

![[Pasted image 20250423142229.png]]

拉伸系数
    //给状态栏添加子控件QLabel* label = new QLabel("这是一个QLabel");statusBar->addWidget(label, 1);QLabel* label2 = new QLabel("这是另一个QLabel");statusBar->addWidget(label2, 2);

![[Pasted image 20250423142405.png]]

添加进度条
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QLabel>
#include <QProgressBar>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//存在就获取,不存在就创建QStatusBar* statusBar = this->statusBar();//如果状态栏没有被创建,这样的设置是必要的//如果状态栏已经在窗口中存在,这样设置的意义不大,但也没有副作用,仍然保留this->setStatusBar(statusBar);//给状态栏添加子控件QLabel* label = new QLabel("这是一个QLabel");statusBar->addWidget(label);QProgressBar* progressBar = new QProgressBar();progressBar->setRange(0, 100);progressBar->setValue(50);statusBar->addWidget(progressBar);
}

![[Pasted image 20250423142642.png]]

添加按钮
    QPushButton* button = new QPushButton("按钮");statusBar->addPermanentWidget(button);

![[Pasted image 20250423142822.png]]

浮动窗⼝

在Qt中,浮动窗⼝也称之为铆接部件。浮动窗⼝是通过QDockWidget类来实现浮动的功能。浮动窗⼝⼀般是位于核⼼部件的周围,可以有多个。

浮动窗⼝的创建

浮动窗⼝的创建是通过QDockWidget类提供的构造⽅法QDockWidget()函数动态创建的;⽰例如下:

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//给主窗口添加一个子窗口QDockWidget* dockWidget = new QDockWidget();//使用addDockWidget把浮动窗口加入到子窗口中this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);
}

![[Pasted image 20250423143822.png]]

    //设置窗口标题dockWidget->setWindowTitle("这是一个浮动窗口");

![[Pasted image 20250423144031.png]]

#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QDockWidget>
#include <QLabel>
#include <QPushButton>
#include <QVBoxLayout>MainWindow::MainWindow(QWidget *parent): QMainWindow(parent), ui(new Ui::MainWindow)
{ui->setupUi(this);//给主窗口添加一个子窗口QDockWidget* dockWidget = new QDockWidget();//使用addDockWidget把浮动窗口加入到子窗口中this->addDockWidget(Qt::LeftDockWidgetArea, dockWidget);//设置窗口标题dockWidget->setWindowTitle("这是一个浮动窗口");//给浮动窗口内部,添加一些其他控件//不能直接给浮动窗口添加子控件,而是要单独创建一个QWidget,把要添加的控件加入到QWidget中//然后再把这个QWidget设置到dockWidget中QWidget* container = new QWidget();dockWidget->setWidget(container);//创建布局管理器,把布局管理器设置到QWidget中QVBoxLayout* layout = new QVBoxLayout;container->setLayout(layout);//创建其他控件QLabel* label = new QLabel("这是一个QLabel");QPushButton* button = new QPushButton("这是按钮");layout->addWidget(label);layout->addWidget(button);
}

![[Pasted image 20250423144803.png]]

    //设置浮动窗口允许停靠位置dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::TopDockWidgetArea);
http://www.dtcms.com/wzjs/465757.html

相关文章:

  • 如何做网站连接nba排名西部和东部
  • 58同城烟台网站建设长沙seo优化推广
  • 做网站有关机械的图片优化排名
  • 网站合作建设方案余姚网站seo运营
  • php做商城网站建设网推获客平台
  • 在哪查网站备案什么是网络营销的核心
  • 厦门建设与管理局网站网站建设是干嘛的
  • 户县建设局网站网站免费进入窗口软件有哪些
  • 怎么样自己建立一个网站福州外包seo公司
  • ppt哪个网站做的好百度网盘客服在线咨询
  • 网站标题是什么上海百度推广
  • 大连网站制作公司58如何在外贸平台推广
  • 织梦做的网站页面打不开推广优化工具
  • 六安招聘网最新招聘百度快速排名优化服务
  • 衡水专业做网站武汉整站优化
  • 在那做网站徐州seo培训
  • 网站栏目划分怎么做上海有什么seo公司
  • wordpress中文视频教程宁波企业seo服务
  • 莆田建设网站视频号的链接在哪
  • 自己做网站免费企业网站定制开发
  • 查互做蛋白的网站优化疫情二十条措施
  • 网站优化标题不超过多少个字符东莞疫情最新消息今天又封了
  • 网站开发大数据营销软文案例
  • 北海做网站上海专业的seo公司
  • wordpress 文章模板网站seo什么意思
  • 成都网站建设公司是什么意思优化设计答案六年级
  • 企业网站商城建设方案知乎怎么申请关键词推广
  • 小公司如何做网站成都百度推广电话号码是多少
  • 做网站设计的提成点是多少培训机构网站
  • php网站发送邮件企业查询网站