Skip to content

Instantly share code, notes, and snippets.

@ssendeavour
Last active December 15, 2015 12:39
Show Gist options
  • Save ssendeavour/5261469 to your computer and use it in GitHub Desktop.
Save ssendeavour/5261469 to your computer and use it in GitHub Desktop.
Gt QHBoxLayout and slot example C++
#include <QtGui/QApplication>
#include <QtGui/QPushButton>
#include <QtGui/QWidget>
#include <QtGui/QSpinBox>
#include <QtGui/QSlider>
#include <QtGui/QHBoxLayout>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *window = new QWidget;
window->setWindowTitle(("&Enter your age"));
QSpinBox *spinBox = new QSpinBox;
QSlider *slider = new QSlider(Qt::Horizontal);
spinBox->setRange(0,130);
slider->setRange(0,130);
QObject::connect(slider,SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
QObject::connect(spinBox,SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
spinBox->setValue(35);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
window->setLayout(layout);
window->show();
return a.exec();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment