[solved] hbox
-
In Qt4 and 5 the QHBox should be used any more. Read the porting site:
"Porting to Qt4":http://qt-project.org/doc/qt-4.8/porting4.html
As mentioned use a QHorizontalLayout and add a QLabel to it.
Greetz -
If you want a Caption over a Layout you can use a QGroupBox with a QHBoxLayout inside
@
QGroupBox *box = new QGroupBox (0);
box->setTitle (tr("Enter your Age"));QHBoxLayout *l = new QHBoxLayout;
l->setSpacing (6);
l->setContentsMargins (6, 6, 6, 6);
// Add Widgets to Layoutbox->setLayout(l);
@ -
now it works, but ...cant understand
-
what is "tr" in 2nd line? ( i deleted it)
error :D:\qt\projS\project2\main.cpp:12: ошибка: 'tr' was not declared in this scope -
@#include <qapplication.h>
#include <qslider.h>
#include <qwidget.h>
#include <qspinbox.h>
#include <QHBoxLayout>
#include <QGroupbox.h>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QGroupBox *hbox = new QGroupBox (0);
hbox->setTitle (("Enter your Age"));
QHBoxLayout *l = new QHBoxLayout;
l->setSpacing (6);
l->setContentsMargins (6, 6, 6, 6);
hbox->setLayout(l);
QSpinBox *spinBox = new QSpinBox(hbox);
QSlider *slider = new QSlider(Qt::Horizontal, hbox);
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);
hbox->show();
return app.exec();
}
@
name of hbox is still "project2"
and margins are not taken into account...cant get it
-
-
-
tr is a static QObject function for translation, since your in main you have to use it like that:
@hbox->setTitle(QObject::tr("Enter your age"));@ -
You are not putting your widgets in your layout.
@l.addWidget(spinBox);
l.addWidget(slider);@
-
-
You're welcome
Since it's solved, don't forget to update the thread's title :)
-
Simply prepend [solved] to your thread's title