#ifndef CONVERTER_H
#define CONVERTER_H
#include <QMainWindow>
#include <QApplication>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QLCDNumber>
#include <QWidget>
Q_OBJECT
public:
Converter();
private:
private slots:
void convert(const QString&);
};
#endif // CONVERTER_H
#ifndef CONVERTER_H
#define CONVERTER_H
#include <QMainWindow>
#include <QApplication>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QLCDNumber>
#include <QWidget>
class QLineEdit;
class Converter : public QWidget {
Q_OBJECT
public:
Converter();
private:
QLineEdit* decEdit;
QLCDNumber* binLCD;
QLCDNumber* hexLCD;
QPushButton* c_Button;
QPushButton* cl_Button;
private slots:
void convert(const QString&);
};
#endif // CONVERTER_H
To copy to clipboard, switch view to plain text mode
#include "Converter.h"
#include <QApplication>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QLCDNumber>
#include <QGridLayout>
Converter::Converter()
{
mainLayout -> addLayout(editLayout);
mainLayout -> addStretch();
mainLayout -> addLayout(ButtonLayout);
editLayout ->addWidget(decLabel,0,0);
editLayout ->addWidget(decEdit,0,1);
editLayout ->addWidget(binLabel,1,0);
editLayout ->addWidget(binLCD,1,1);
editLayout ->addWidget(hexLabel,2,0);
editLayout ->addWidget(hexLCD,2,1);
editLayout ->addWidget(c_Button,0,2);
editLayout ->addWidget(cl_Button,4,1);
this ->setWindowTitle("Decimal to Bin/Hex Converter");
connect(c_Button,
SIGNAL(clicked
()),
this,
SLOT(convert
(QString)));
connect(cl_Button,SIGNAL(clicked()),this, SLOT(clearAll()));
}
void Converter::convert(const QString& newValue)
{
int num = newValue.toInt();
//hexLCD->setHexMode(newValue);
// binLCD->setHexMode(QString::number(num,2));
}
#include "Converter.h"
#include <QApplication>
#include <QPushButton>
#include <QTextEdit>
#include <QVBoxLayout>
#include <QDebug>
#include <QLabel>
#include <QLineEdit>
#include <QLCDNumber>
#include <QGridLayout>
Converter::Converter()
{
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QGridLayout * editLayout = new QGridLayout;
QHBoxLayout *ButtonLayout = new QHBoxLayout;
mainLayout -> addLayout(editLayout);
mainLayout -> addStretch();
mainLayout -> addLayout(ButtonLayout);
QLabel *decLabel = new QLabel(tr("Enter an Interger"));
QLabel *binLabel = new QLabel(tr("Binary"));
QLabel *hexLabel = new QLabel(tr("Hexadecimal"));
decEdit = new QLineEdit;
hexLCD = new QLCDNumber();
binLCD = new QLCDNumber();
c_Button = new QPushButton("&Convert");
cl_Button = new QPushButton("&ClearAll");
editLayout ->addWidget(decLabel,0,0);
editLayout ->addWidget(decEdit,0,1);
editLayout ->addWidget(binLabel,1,0);
editLayout ->addWidget(binLCD,1,1);
editLayout ->addWidget(hexLabel,2,0);
editLayout ->addWidget(hexLCD,2,1);
editLayout ->addWidget(c_Button,0,2);
editLayout ->addWidget(cl_Button,4,1);
this ->setWindowTitle("Decimal to Bin/Hex Converter");
connect(c_Button,SIGNAL(clicked()),this, SLOT(convert(QString)));
connect(cl_Button,SIGNAL(clicked()),this, SLOT(clearAll()));
}
void Converter::convert(const QString& newValue)
{
int num = newValue.toInt();
//hexLCD->setHexMode(newValue);
// binLCD->setHexMode(QString::number(num,2));
}
To copy to clipboard, switch view to plain text mode
#include<QApplication>
#include"Converter.h"
int main(int argc, char *argv[])
{
Converter c;
c.setAttribute(Qt::WA_QuitOnClose);
c.show();
return app.exec();
}
#include<QApplication>
#include"Converter.h"
int main(int argc, char *argv[])
{
QApplication app(argc,argv);
Converter c;
c.setAttribute(Qt::WA_QuitOnClose);
c.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks