Hi I am a beginner in programming in C++ with Qt 4, I must write a program to ask the user for a Temperature in Celcius using QInputDialog, I wrote the header with the class and .cpp wiht the fucnction file, but are battling calling the function in the main.cpp. Please advice me on where I went wrong:
Header:
#ifndef INPUTDIALOG_H
#define INPUTDIALOG_H
class InputDialog
{
public:
~InputDialog();
void getTemp();
private slots:
private:
};
#endif // INPUTDIALOG_H
InputDialog.cpp:
#include "inputdialog.h"
#include <QWidget>
#include <QInputDialog>
#include <QMessageBox>
#include <QObject>
#include <QLabel>
InputDialog::~InputDialog()
{
}
void InputDialog::getTemp()
{
bool (ok);
int *temperature = QInputDialog::getInt(temperature,tr("Enter a Temperature in Celsius"),tr("Celsius"),0,-30,100,1,&ok);
if (ok)
integerLable->setText(tr("%1%").arg(temperature));
}
Main.cpp:
#include <QtGui/QApplication>
#include "inputdialog.h"
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
InputDialog.getTemp();
return app.exec();
}
Bookmarks