这个小部件我将用作模式切换器.你见过这样的东西吗?
解决方法 我会使用附带QLabel的QSlIDer,如下所示.我通常的免责声明是你可能需要自己进行一些微调和调整.main.cpp中
#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();}
main.pro
TEMPLATE = appTARGET = mainQT += WidgetsSOURCES += main.cpp
构建并运行
qmake && make && ./main总结
以上是内存溢出为你收集整理的c – 带刻度文本标签的Qt滑块小部件全部内容,希望文章能够帮你解决c – 带刻度文本标签的Qt滑块小部件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)