alberthrocks

dummy.cpp

Jan 26th, 2016
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include "dummy.h"
  2.  
  3. MainWindow::MainWindow()
  4. {
  5.     slider = new QSlider(Qt::Horizontal);
  6.     slider->setMinimum(0);
  7.     slider->setMaximum(100);
  8.     lineEdit = new QLineEdit();
  9.  
  10.     QObject::connect(slider, SIGNAL(valueChanged(int)),
  11.                      this, SLOT(onValueChanged(int)));
  12.  
  13.     QVBoxLayout *layout = new QVBoxLayout();
  14.     layout->addWidget(slider);
  15.     layout->addWidget(lineEdit);
  16.  
  17.     QWidget *wrapper = new QWidget();
  18.     wrapper->setLayout(layout);
  19.     setCentralWidget(wrapper);
  20. }
  21.  
  22. MainWindow::~MainWindow()
  23. {
  24. }
  25.  
  26. void MainWindow::onValueChanged(int value)
  27. {
  28.     int pos;
  29.    
  30.     printf("Enter onValueChanged\n");
  31.    
  32.     pos = slider->sliderPosition();
  33.     QString text = QString::number(pos);
  34.     lineEdit->setText(text);
  35.    
  36.     QMessageBox::StandardButton reply;
  37.     reply = QMessageBox::question(this, "Test", "Just a test!",
  38.                                 QMessageBox::Yes|QMessageBox::No);
  39.    
  40.     printf("Exit onValueChanged\n");
  41. }
  42.  
  43. int main(int argc, char *argv[])
  44. {
  45.     QApplication app(argc, argv);
  46.     MainWindow mainWindow;
  47.     mainWindow.show();
  48.     return app.exec();
  49. }
Advertisement
Add Comment
Please, Sign In to add comment