Qt-2-Varsta-Age-Tutorial: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
@#include "varsta.h" | |||
#include <QApplication> | |||
#include <QSpinBox> | |||
#include <QSlider> | |||
#include <QHBoxLayout> | |||
int main(int argc, char *argv[]) | int main(int argc, char *argv[]) | ||
{ | |||
QApplication a(argc, argv); | |||
QWidget *w = new QWidget; | |||
w->setWindowTitle("Introduceti varsta dvs."); | |||
QSpinBox *spinBox = new QSpinBox; | QSpinBox *spinBox = new QSpinBox; | ||
QSlider *slider = new QSlider(Qt::Horizontal); | |||
spinBox->setRange(0,130); | |||
slider->setRange(0,130); | |||
QObject::connect(spinBox, SIGNAL (valueChanged(int)), slider, SLOT (setValue(int))); | QObject::connect(spinBox, SIGNAL (valueChanged(int)), slider, SLOT (setValue(int))); | ||
QObject::connect(slider, SIGNAL (valueChanged(int)), spinBox, SLOT (setValue(int))); | |||
spinBox->setValue(35); | |||
QHBoxLayout *layout = new QHBoxLayout; | QHBoxLayout *layout = new QHBoxLayout; | ||
layout->addWidget(spinBox); | |||
layout->addWidget(slider); | |||
w->setLayout(layout); | |||
w- | w->show(); | ||
return a.exec | return a.exec(); | ||
} | |||
<code> |
Revision as of 13:01, 25 February 2015
@#include "varsta.h"
- include <QApplication>
- include <QSpinBox>
- include <QSlider>
- include <QHBoxLayout>
int main(int argc, char *argv[]) {
QApplication a(argc, argv); QWidget *w = new QWidget; w->setWindowTitle("Introduceti varsta dvs.");
QSpinBox *spinBox = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal); spinBox->setRange(0,130); slider->setRange(0,130);
QObject::connect(spinBox, SIGNAL (valueChanged(int)), slider, SLOT (setValue(int)));
QObject::connect(slider, SIGNAL (valueChanged(int)), spinBox, SLOT (setValue(int))); spinBox->setValue(35);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinBox); layout->addWidget(slider); w->setLayout(layout);
w->show();
return a.exec();
}