S
S
sabn1k2016-02-16 12:31:08
Qt
sabn1k, 2016-02-16 12:31:08

'class GHBoxLayout' has no membered named 'addWidget'?

In Summerfield's book, I took an example and inserted it into Qt, but an error pops up.

#include "widget.h"
#include <QApplication>
#include <QPushButton>
#include <QSlider>
#include <QSpinBox>
#include <QHBoxLayout>
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    QWidget *window = new QWidget;
    window->setWindowTitle("Введите имя: ");
    QSpinBox *spinBox = new QSpinBox;
    QSlider *slider = new QSlider(Qt::Vertical);
    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->addWiget(spinBox);
    layout->addWiget(slider);
    window->setLayout(layout);
    window->show();
    return a.exec();
}

Answer the question

In order to leave comments, you need to log in

3 answer(s)
J
Jacob E, 2016-02-16
@sabn1k

We have to guess the error ourselves, right?

V
Vladimir Martyanov, 2016-02-16
@vilgeforce

What version of Qt?

S
sabn1k, 2016-02-16
@sabn1k

Oh God, what an idiot I am.

layout->addWiget(spinBox);
layout->addWiget(slider);

wiGet instead of wiDGet...
Sorry for the stupid noise.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question