Hi im brand new to c++ and trying to get my head around the concepts. I am creating a very simple app to get going with the help of the tutorials, so im trying to do my own first try. I'm having problems with the file.h and file.cpp the one besides main.cpp I would like to click the button in the button box "ok" and have text come up in the text box. Here is MainWindow.h first
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include "ui_MainWindow.h"
class MainWindow: public QMainWindow, private Ui::MainWindow
{
Q_OBJECT
public:
MainWindow(QMainWindow *parent = 0);
private slots:
//here is where im tyring to add a slot.
void on_buttonbox_buttonClicked ( QAbstractButton * );
// void on_inputSpinBox2_valueChanged(int value);
private:
Ui::MainWindow ui;
};
#endif
Next is the MainWindow.cpp
#include <QtGui>
#include "MainWindow.h"
MainWindow::MainWindow(QMainWindow *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
}
//This is where i would like to catch the clicked signal from the ok button and add the text to the text box.
void MainWindow::on_buttonbox_buttonClicked ( QAbstractButton * ){
ui.textEdit->setText(QString::number(16));
}
Im trying to be as simple as posible to just to get it going, it will compile but i can't get the signals and slots to talk, where am i going wrong.... remember brand new.
You have to connect your Slots to the Signals, add this into your constructor:
Also please see here: http://qt-project.org/doc/qt-4.8/signalsandslots.html
Edit:
MainWindow.cpp
But don't forget to change
yourButton
to whatever you've named yours.