Hello

I try to use the 'Knob'. I turn the 'Knob' but the value of the label isn't changed.

66.png

Knob.pro
Qt Code:
  1. SOURCES += \
  2. main.cpp \
  3. mainwindow.cpp
  4.  
  5. HEADERS += \
  6. mainwindow.h
  7.  
  8. QWT_LOCATION = c:/Qwt-6.0.2
  9. INCLUDEPATH += $${QWT_LOCATION}/include
  10. LIBS = -L$${QWT_LOCATION}/lib \
  11. -lqwt
To copy to clipboard, switch view to plain text mode 

main.cpp
Qt Code:
  1. #include <QApplication>
  2. #include "mainwindow.h"
  3.  
  4. int main(int argc, char **argv)
  5. {
  6. QApplication app(argc, argv);
  7.  
  8. MainWindow mw;
  9. mw.show();
  10.  
  11. return app.exec();
  12. }
To copy to clipboard, switch view to plain text mode 

mainwindow.h
Qt Code:
  1. #ifndef MAINWINDOW_H
  2. #define MAINWINDOW_H
  3.  
  4. #include <QMainWindow>
  5.  
  6. class QLabel;
  7. class QwtKnob;
  8.  
  9. class MainWindow : public QMainWindow
  10. {
  11. Q_OBJECT
  12. public:
  13. explicit MainWindow(QWidget *parent = 0);
  14.  
  15. signals:
  16.  
  17. private slots:
  18. void setValueOfLabel(double value);
  19.  
  20. private:
  21. QLabel *label;
  22. QwtKnob *knob;
  23. };
  24.  
  25. #endif // MAINWINDOW_H
To copy to clipboard, switch view to plain text mode 

mainwindow.cpp
Qt Code:
  1. #include "mainwindow.h"
  2. #include <qwt_knob.h>
  3. #include <QVBoxLayout>
  4. #include <QWidget>
  5. #include <QLabel>
  6.  
  7. MainWindow::MainWindow(QWidget *parent) :
  8. QMainWindow(parent)
  9. {
  10. knob = new QwtKnob;
  11. label = new QLabel(QString::number(knob->value()));
  12.  
  13. QVBoxLayout *mainLayout = new QVBoxLayout;
  14. mainLayout->addWidget(label, 0, Qt::AlignCenter);
  15. mainLayout->addWidget(knob);
  16.  
  17. QWidget *window = new QWidget;
  18. window->setLayout(mainLayout);
  19.  
  20. setCentralWidget(window);
  21.  
  22. this->setWindowTitle(tr("Knob"));
  23.  
  24. connect(knob, SIGNAL(valueChanged(double)), label, SLOT(setValueOfLabel(double )));
  25. }
  26.  
  27. void MainWindow::setValueOfLabel(double value)
  28. {
  29. label->setText(QString::number(value));
  30. }
To copy to clipboard, switch view to plain text mode 

Ivan

Thanks