大佬教程收集整理的这篇文章主要介绍了c – 带刻度文本标签的Qt滑块小部件,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
#include <QMainWindow> #include <QApplication> #include <QGridLayout> #include <QSlider> #include <QLabel> class MainWindow Q_DECL_FINAL : public QMainWindow { Q_OBjeCT public: explicit MainWindow(QWidget *parent = Q_NULLPTR) : QMainWindow(parent) { QSlider *slider = new QSlider(Qt::Horizontal,this); slider->setRange(1,4); slider->setSingleStep(1); QLabel *label1 = new QLabel("Novice",this); QLabel *label2 = new QLabel("Intermediate",this); QLabel *label3 = new QLabel("Advanced",this); QLabel *label4 = new QLabel("Expert",this); QGridLayout *layout = new QGridLayout; layout->addWidget(slider,1,4); layout->addWidget(label1,1); layout->addWidget(label2,1); layout->addWidget(label3,2,1); layout->addWidget(label4,3,1); setLayout(layout); } }; #include "main.moc" int main(int argc,char **argv) { QApplication application(argc,argv); MainWindow mainWindow; mainWindow.show(); return application.exec(); }@H_971_2@main.pro
TEMPLATE = app TARGET = main QT += widgets sourcES += main.cpp
构建并运行
qmake && make && ./main
以上是大佬教程为你收集整理的c – 带刻度文本标签的Qt滑块小部件全部内容,希望文章能够帮你解决c – 带刻度文本标签的Qt滑块小部件所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。