Qt-2-Varsta-Age-Tutorial: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
<code>#include &quot;varsta.h&amp;quot;<br />#include &lt;QApplication&amp;gt;<br />#include &lt;QSpinBox&amp;gt;<br />#include &lt;QSlider&amp;gt;<br />#include &lt;QHBoxLayout&amp;gt;
@#include "varsta.h"
#include <QApplication>
#include <QSpinBox>
#include <QSlider>
#include <QHBoxLayout>


int main(int argc, char *argv[])<br />{<br /> QApplication a(argc, argv);<br /> QWidget *w = new QWidget;<br /> w-&gt;setWindowTitle(&quot;Introduceti varsta dvs.&quot;);
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QWidget *w = new QWidget;
w->setWindowTitle("Introduceti varsta dvs.");


QSpinBox *spinBox = new QSpinBox;<br /> QSlider *slider = new QSlider(Qt::Horizontal);<br /> spinBox-&gt;setRange(0,130);<br /> slider-&gt;setRange(0,130);
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)));<br /> QObject::connect(slider, SIGNAL (valueChanged(int)), spinBox, SLOT (setValue(int)));<br /> spinBox-&gt;setValue(35);
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;<br /> layout-&gt;addWidget(spinBox);<br /> layout-&gt;addWidget(slider);<br /> w-&gt;setLayout(layout);
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(spinBox);
layout->addWidget(slider);
w->setLayout(layout);


w-&gt;show();
w->show();


return a.exec&amp;amp;#40;&amp;#41;;<br />}<br /></code>
return a.exec();
}
<code>

Revision as of 13:01, 25 February 2015

@#include "varsta.h"

  1. include <QApplication>
  2. include <QSpinBox>
  3. include <QSlider>
  4. 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(); }