当前位置:网站首页>QT: 手工布局并关联QSpin和QSlider
QT: 手工布局并关联QSpin和QSlider
2022-06-09 06:25:00 【CoderIsArt】
1.创建一个控制台工程LayoutWidgets

2. 修改工程文件
QT += gui widgets
3. 修改主程序main.cpp如下,
#include <QApplication>
#include <QHBoxLayout>
#include <QSlider>
#include <QSpinBox>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *window = new QWidget();
window->setWindowTitle("Enter your Age");QSpinBox *spinBox = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);
spinBox->setRange(0,150);
slider->setRange(0,150);
QObject::connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
QObject::connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
spinBox->setValue(45);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
window->setLayout(layout);
window->resize(300,80);
window->show();
return a.exec();
}
4. 运行结果,

边栏推荐
- Quanzhi v3s learning record (11) audio and video Usage Summary
- 戒烟日志_02 (day_06)
- Introduction to bladed fault simulation method
- “TypeError: ‘list‘ object is not callable”
- Exponential moving weighted average
- Bladed sequential wind configuration method
- 深度学习之二手手机价格预测
- CodeBlocks always repeat the last result
- MT2712 SOC DMIPS
- Complex process mining technology hidden behind civilian products - an exclusive interview with chaiyatuan, founder of Rongzhi information
猜你喜欢

MySQL联合查询(多表查询)

Implementation of Excel piecewise linear interpolation function

全志H3停产,A40I/T3更胜一筹--CoM-X40I核心模块来了

Coredns part 4-compiling and installing unbound

Powerdns 1- introduction and installation

二叉树的递归套路

全志平台BSP裁剪(6)附件三--rootfs menuconfig配置说明

Recursive routines of binary trees

Coredns Part 1 Introduction and installation

全国产工业级全志T3/A40i核心板-CoM-X40I,助力智能电力系统
随机推荐
MySQL 联合查询
adam 神经网络
Bladed software windfile calculation
微信小程序页面滚动至底部
The performance comparison of Quanzhi T3 (a40i) /t5 (t507) is better than that of the previous generation
Bladed software display incomplete solution
戒烟日志_02 (day_06)
RNN and its improved version (with 2 code cases attached)
Wechat applet page scrolls to the bottom
DNS principles 01 introduction to DNS principles
Principales différences entre CMS et G1
Solution d'instructeur de robot basée sur l'enregistrement complet a40i fabriqué en Chine
Conversion of data type real and word in PROFIBUS DP communication
mockito 无返回值方法及异常mock
Comparison between ZGC and G1 and the meaning of color points
Yocto compiling libdrm
香蕉派 BPI-M2 Ultra的缩小版-CoM-X40I核心板
Comparison between the most cost-effective processor and domestic processor i.mx6ul/a40i/t3
MT2712 SOC DMIPS
Bat renames files (folders) in batch