I was following a signal&slot tutorial I found out on youtube on how to create a progressBar and horizontalSlider just by coding, without drag&drop.
This is the code (mainwindow.cpp file):
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow
::MainWindow(QWidget *parent
) : ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->horizontalSlider,
SIGNAL(valueChanged(int)),
ui->progressBar,
SLOT(setValue(int)));
}
MainWindow::~MainWindow()
{
delete ui;
}
#include "mainwindow.h"
#include "ui_mainwindow.h"
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
connect(ui->horizontalSlider,
SIGNAL(valueChanged(int)),
ui->progressBar,
SLOT(setValue(int)));
}
MainWindow::~MainWindow()
{
delete ui;
}
To copy to clipboard, switch view to plain text mode
As you see, all the job was to add the text in the constructor.
It fails to compile on my laptop: "class Ui::MainWindow has no member named horizontalSlider and class Ui::MainWindow has no member named progressBar".
However on the video I was following it compiles and the author didn't make any additional writings.
I would highly appreciate your suggestions, guys.
I'm using Qt 5.4.1, maybe it's because of version inconsistencies and that tutorial is outdated?
Bookmarks