//! [0] Calculator::Calculator(QWidget *parent) : QWidget(parent) { sumInMemory = 0.0; sumSoFar = 0.0; factorSoFar = 0.0; waitingForOperand = true; //! [0] //! [1] display = new QLineEdit("0"); //! [1] //! [2] display->setReadOnly(true); display->setAlignment(Qt::AlignRight); display->setMaxLength(15); QFont font = display->font(); font.setPointSize(font.pointSize() + 8); display->setFont(font); //! [2] //! [4] for (int i = 0; i < NumDigitButtons; ++i) { digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); } Button *pointButton = createButton(tr("."), SLOT(pointClicked())); Button *changeSignButton = createButton(tr("\302\261"), SLOT(changeSignClicked())); Button *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); Button *clearButton = createButton(tr("Clear"), SLOT(clear())); Button *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); Button *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); Button *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); Button *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); Button *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); Button *divisionButton = createButton(tr("\303\267"), SLOT(multiplicativeOperatorClicked())); Button *timesButton = createButton(tr("\303\227"), SLOT(multiplicativeOperatorClicked())); Button *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); Button *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); Button *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); Button *powerButton = createButton(tr("x\302\262"), SLOT(unaryOperatorClicked())); Button *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); Button *equalButton = createButton(tr("="), SLOT(equalClicked())); //! [4] //! [5] QGridLayout *mainLayout = new QGridLayout; //! [5] //! [6] mainLayout->setSizeConstraint(QLayout::SetFixedSize); mainLayout->addWidget(display, 0, 0, 1, 6); mainLayout->addWidget(backspaceButton, 1, 0, 1, 2); mainLayout->addWidget(clearButton, 1, 2, 1, 2); mainLayout->addWidget(clearAllButton, 1, 4, 1, 2); mainLayout->addWidget(clearMemoryButton, 2, 0); mainLayout->addWidget(readMemoryButton, 3, 0); mainLayout->addWidget(setMemoryButton, 4, 0); mainLayout->addWidget(addToMemoryButton, 5, 0); for (int i = 1; i < NumDigitButtons; ++i) { int row = ((9 - i) / 3) + 2; int column = ((i - 1) % 3) + 1; mainLayout->addWidget(digitButtons[i], row, column); } mainLayout->addWidget(digitButtons[0], 5, 1); mainLayout->addWidget(pointButton, 5, 2); mainLayout->addWidget(changeSignButton, 5, 3); mainLayout->addWidget(divisionButton, 2, 4); mainLayout->addWidget(timesButton, 3, 4); mainLayout->addWidget(minusButton, 4, 4); mainLayout->addWidget(plusButton, 5, 4); mainLayout->addWidget(squareRootButton, 2, 5); mainLayout->addWidget(powerButton, 3, 5); mainLayout->addWidget(reciprocalButton, 4, 5); mainLayout->addWidget(equalButton, 5, 5); setLayout(mainLayout); setWindowTitle(tr("Calculator")); }
CalculatorScientific::CalculatorScientific(QWidget *parent) : QMainWindow(parent), ui(new Ui::CalculatorScientific) { setFixedSize(530,355); ui->setupUi(this); sumInMemory = 0.0; sumSoFar = 0.0; factorSoFar = 0.0; waitingForOperand = true; // ui->radioButton_10->setChecked(true); ui->radioButton_Angle->setChecked(true); //NumberKey connect(ui->pushButton_Zero, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_One, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Two, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Three, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Four, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Five, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Six, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Seven, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Eight, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Nine, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_A, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_B, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_C, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_D, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_E, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_F, SIGNAL(clicked()), this, SLOT(digitClicked())); connect(ui->pushButton_Pi, SIGNAL(clicked()), this, SLOT(digitClicked())); // connect(ui->pushButton_Point, SIGNAL(clicked()), this ,SLOT(pointClicked())); connect(ui->pushButton_PlusMinus, SIGNAL(clicked()), this, SLOT(changeSignClicked())); // connect(ui->pushButton_Backspace, SIGNAL(clicked()), this, SLOT(backspaceClicked())); connect(ui->pushButton_Clear, SIGNAL(clicked()), this, SLOT(clear())); connect(ui->pushButton_ClearAll, SIGNAL(clicked()), this, SLOT(clearAll())); //OperatorKey connect(ui->pushButton_Add, SIGNAL(clicked()), this, SLOT(additiveOperatorClicked())); connect(ui->pushButton_Sub, SIGNAL(clicked()), this, SLOT(additiveOperatorClicked())); connect(ui->pushButton_Mul, SIGNAL(clicked()), this, SLOT(multiplicativeOperatorClicked())); connect(ui->pushButton_Div, SIGNAL(clicked()), this, SLOT(multiplicativeOperatorClicked())); connect(ui->pushButton_Mod, SIGNAL(clicked()), this, SLOT(additiveOperatorClicked())); connect(ui->pushButton_And, SIGNAL(clicked()), this, SLOT(additiveOperatorClicked())); connect(ui->pushButton_Xor, SIGNAL(clicked()), this, SLOT(additiveOperatorClicked())); connect(ui->pushButton_X_y, SIGNAL(clicked()), this, SLOT(additiveOperatorClicked())); // connect(ui->pushButton_, SIGNAL(clicked()), this, SLOT(additiveOperatorClicked())); // connect(ui->pushButton_Sqrt, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_X_2, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_X_3, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Ln, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Log, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Sin,SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Sinh, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Cos, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Cosh, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Tan, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Tanh, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Fac, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_E_x, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_10_x, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Int, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Not, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Derivative, SIGNAL(clicked()), this, SLOT(unaryOperatorClicked())); connect(ui->pushButton_Equl, SIGNAL(clicked()), this, SLOT(equalClicked())); //M connect(ui->pushButton_MC, SIGNAL(clicked()), this, SLOT(clearMemory())); connect(ui->pushButton_MR, SIGNAL(clicked()), this, SLOT(readMemory())); connect(ui->pushButton_MS, SIGNAL(clicked()), this ,SLOT(setMemory())); connect(ui->pushButton_MPlus,SIGNAL(clicked()), this, SLOT(addToMemory())); connect(ui->pushButton_MMinus, SIGNAL(clicked()), this, SLOT(subToMemory())); }
/******************************************************************************** * Description : Constructeur par paramètre de la calculatrice. Permet de générer une calculatrice sur mesure. * Paramètres : *parent * Type de retour : void *******************************************************************************/ Calculatrice::Calculatrice(QWidget *parent): QWidget(parent) { sumInMemory = 0.0; sumSoFar = 0.0; factorSoFar = 0.0; waitingForOperand = true; //creation d'un objet de type QLineEdit avec par défaut la chaine de caractère 0 //cette objet représente une zone de texte qui sera utilisé comme afficheur de la calculatrice display = new QLineEdit("0"); // la zone de texte est paramétrée en lecture seule display->setReadOnly(true); // l'affichage se fera de la droite vers la gauche display->setAlignment(Qt::AlignRight); // définition de la largeur de la zone de texte à 15 display->setMaxLength(15); QFont font = display->font(); font.setPointSize(font.pointSize() + 8); display->setFont(font); //MaFenetre fenetre1; for(int i=0; i<NumDigitButtons; ++i) { digitButtons[i] = createButton(QString::number(i), SLOT(digitClicked())); } Bouton *pointButton = createButton(tr("."), SLOT(pointClicked())); Bouton *changeSignButton = createButton(tr("\261"), SLOT(changeSignClicked())); Bouton *backspaceButton = createButton(tr("Backspace"), SLOT(backspaceClicked())); Bouton *clearButton = createButton(tr("Clear"), SLOT(clear())); Bouton *clearAllButton = createButton(tr("Clear All"), SLOT(clearAll())); //Mes boutons Bouton *clearMemoryButton = createButton(tr("MC"), SLOT(clearMemory())); Bouton *readMemoryButton = createButton(tr("MR"), SLOT(readMemory())); Bouton *setMemoryButton = createButton(tr("MS"), SLOT(setMemory())); Bouton *addToMemoryButton = createButton(tr("M+"), SLOT(addToMemory())); Bouton *divisionButton = createButton(tr("\367"), SLOT(multiplicativeOperatorClicked())); Bouton *timesButton = createButton(tr("\327"), SLOT(multiplicativeOperatorClicked())); Bouton *minusButton = createButton(tr("-"), SLOT(additiveOperatorClicked())); Bouton *plusButton = createButton(tr("+"), SLOT(additiveOperatorClicked())); Bouton *squareRootButton = createButton(tr("Sqrt"), SLOT(unaryOperatorClicked())); Bouton *powerButton = createButton(tr("x\262"), SLOT(unaryOperatorClicked())); Bouton *reciprocalButton = createButton(tr("1/x"), SLOT(unaryOperatorClicked())); Bouton *equalButton = createButton(tr("="), SLOT(equalClicked())); //Déclarez votre layout ici QGridLayout *mainLayout = new QGridLayout(); //Gerer le positionnement des boutons sur le layout ici //section d'affichage de la calculatrice mainLayout->addWidget(display,0,0,1,6); //bouton d'effacage d'un seul élément de la calculatrice mainLayout->addWidget(backspaceButton,1,0,1,2); //bouton effacant completement l'affichage de la calculatrice mainLayout->addWidget(clearButton,1,2,1,2); //bouton effacant l'affichage ainsi que la mémoire de la calculatrice mainLayout->addWidget(clearAllButton,1,4,1,2); //bouton effacant la mémoire de la calculatrice mainLayout->addWidget(clearMemoryButton,2,0); //bouton représentant le nombre 7 mainLayout->addWidget(digitButtons[7],2,1); //bouton représentant le nombre 8 mainLayout->addWidget(digitButtons[8],2,2); //bouton représentant le nombre 9 mainLayout->addWidget(digitButtons[9],2,3); //bouton effectuant l'operation de division mainLayout->addWidget(divisionButton,2,4); //bouton effectuant l'opération racine carrée mainLayout->addWidget(squareRootButton,2,5); //bouton affichant le contenu de la mémoire de la calculatrice mainLayout->addWidget(readMemoryButton,3,0); //bouton représentant le nombre 4 mainLayout->addWidget(digitButtons[4],3,1); //bouton représentant le nombre 5 mainLayout->addWidget(digitButtons[5],3,2); //bouton représentant le nombre 6 mainLayout->addWidget(digitButtons[6],3,3); //bouton effectuant l'opération de multiplication mainLayout->addWidget(timesButton,3,4); //bouton mettant la valeur affichée au carrée mainLayout->addWidget(powerButton,3,5); //bouton mettant la valeur affichée en mémoire de la calculatrice mainLayout->addWidget(setMemoryButton,4,0); //bouton représentant le nombre 1 mainLayout->addWidget(digitButtons[1],4,1); //bouton représentant le nombre 2 mainLayout->addWidget(digitButtons[2],4,2); //bouton représentant le nombre 3 mainLayout->addWidget(digitButtons[3],4,3); //bouton effectuant l'opération de soustraction mainLayout->addWidget(minusButton,4,4); //bouton effectuant l'opération réciproque (x -> 1/x) mainLayout->addWidget(reciprocalButton,4,5); //bouton effectuant une addition avec ce qui se trouve en mémoire de la calculatrice mainLayout->addWidget(addToMemoryButton,5,0); //bouton représentant le nombre 0 mainLayout->addWidget(digitButtons[0],5,1); //bouton permettant d'ajouter un point au nombre affiché pour faire un float mainLayout->addWidget(pointButton,5,2); //bouton effectuant un changement de signe sur le nombre affiché mainLayout->addWidget(changeSignButton,5,3); //bouton effectuant l'opération d'addition mainLayout->addWidget(plusButton,5,4); //bouton qui affiche la réponse de l'opération effectuée précédement mainLayout->addWidget(equalButton,5,5); // Ajout du layout à la fenetre principale setLayout(mainLayout); // Ajout du titre de la fenetre setWindowTitle(tr("Calculatrice")); }
/* * Constructs a MiniCalc as a child of 'parent', with the * name 'name' and widget flags set to 'f'. * * The dialog will by default be modeless, unless you set 'modal' to * TRUE to construct a modal dialog. */ MiniCalc::MiniCalc( QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { if ( !name ) setName( "MiniCalc" ); setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 1, 1, sizePolicy().hasHeightForWidth() ) ); MiniCalcLayout = new QGridLayout( this, 1, 1, 1, 1, "MiniCalcLayout"); MiniCalcLayout->setResizeMode( QLayout::Fixed ); sumInMemory = 0.0; sumSoFar = 0.0; factorSoFar = 0.0; waitingForOperand = true; calcFrame = new QFrame( this, "calcFrame" ); calcFrame->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, calcFrame->sizePolicy().hasHeightForWidth() ) ); calcFrame->setFrameShape( QFrame::StyledPanel ); calcFrame->setFrameShadow( QFrame::Raised ); calcFrameLayout = new QGridLayout( calcFrame, 1, 1, 1, 1, "calcFrameLayout"); extMem = new QPushButton( calcFrame, "extMem" ); extMem->setMaximumSize( QSize( 25, 25 ) ); extMem->setPaletteBackgroundColor( QColor( 205, 205, 205 ) ); QFont extMem_font( extMem->font() ); extMem_font.setPointSize( 8 ); extMem->setFont( extMem_font ); extMem->setToggleButton( TRUE ); calcFrameLayout->addWidget( extMem, 0, 0 ); display = new QLineEdit( calcFrame, "display" ); QFont display_font( display->font() ); display_font.setFamily( "xos4 Terminus" ); display_font.setPointSize( 11 ); display->setFont( display_font ); display->setText("0"); display->setReadOnly(true); display->setAlignment(Qt::AlignRight); display->setMaxLength(15); display->installEventFilter(this); calcFrameLayout->addMultiCellWidget( display, 0, 0, 1, 5 ); toDocButton = new QPushButton( calcFrame, "toDocButton" ); toDocButton->setMaximumSize( QSize( 25, 25 ) ); toDocButton->setPaletteBackgroundColor( QColor( 200, 200, 250 ) ); QFont toDocButton_font( toDocButton->font() ); toDocButton_font.setPointSize( 8 ); toDocButton->setFont( toDocButton_font ); calcFrameLayout->addWidget( toDocButton, 0, 6 ); clearMemoryButton = new QPushButton( calcFrame, "clearMemoryButton" ); clearMemoryButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, clearMemoryButton->sizePolicy().hasHeightForWidth() ) ); clearMemoryButton->setMaximumSize( QSize( 25, 25 ) ); clearMemoryButton->setPaletteBackgroundColor( QColor( 205, 205, 205 ) ); QFont clearMemoryButton_font( clearMemoryButton->font() ); clearMemoryButton_font.setPointSize( 8 ); clearMemoryButton->setFont( clearMemoryButton_font ); calcFrameLayout->addWidget( clearMemoryButton, 1, 0 ); btn_7 = new QPushButton( calcFrame, "btn_7" ); btn_7->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_7->sizePolicy().hasHeightForWidth() ) ); btn_7->setMaximumSize( QSize( 25, 25 ) ); QFont btn_7_font( btn_7->font() ); btn_7_font.setPointSize( 8 ); btn_7->setFont( btn_7_font ); calcFrameLayout->addWidget( btn_7, 1, 1 ); btn_8 = new QPushButton( calcFrame, "btn_8" ); btn_8->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_8->sizePolicy().hasHeightForWidth() ) ); btn_8->setMaximumSize( QSize( 25, 25 ) ); QFont btn_8_font( btn_8->font() ); btn_8_font.setPointSize( 8 ); btn_8->setFont( btn_8_font ); calcFrameLayout->addWidget( btn_8, 1, 2 ); btn_9 = new QPushButton( calcFrame, "btn_9" ); btn_9->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_9->sizePolicy().hasHeightForWidth() ) ); btn_9->setMaximumSize( QSize( 25, 25 ) ); QFont btn_9_font( btn_9->font() ); btn_9_font.setPointSize( 8 ); btn_9->setFont( btn_9_font ); calcFrameLayout->addWidget( btn_9, 1, 3 ); plusButton = new QPushButton( calcFrame, "plusButton" ); plusButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, plusButton->sizePolicy().hasHeightForWidth() ) ); plusButton->setMaximumSize( QSize( 25, 25 ) ); plusButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont plusButton_font( plusButton->font() ); plusButton_font.setPointSize( 8 ); plusButton->setFont( plusButton_font ); calcFrameLayout->addWidget( plusButton, 1, 4 ); changeSignButton = new QPushButton( calcFrame, "changeSignButton" ); changeSignButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, changeSignButton->sizePolicy().hasHeightForWidth() ) ); changeSignButton->setMaximumSize( QSize( 25, 25 ) ); changeSignButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont changeSignButton_font( changeSignButton->font() ); changeSignButton_font.setPointSize( 8 ); changeSignButton->setFont( changeSignButton_font ); calcFrameLayout->addWidget( changeSignButton, 1, 5 ); clearButton = new QPushButton( calcFrame, "clearButton" ); clearButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, clearButton->sizePolicy().hasHeightForWidth() ) ); clearButton->setMaximumSize( QSize( 25, 25 ) ); clearButton->setPaletteBackgroundColor( QColor( 250, 200, 200 ) ); QFont clearButton_font( clearButton->font() ); clearButton_font.setPointSize( 8 ); clearButton->setFont( clearButton_font ); calcFrameLayout->addWidget( clearButton, 1, 6 ); readMemoryButton = new QPushButton( calcFrame, "readMemoryButton" ); readMemoryButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, readMemoryButton->sizePolicy().hasHeightForWidth() ) ); readMemoryButton->setMaximumSize( QSize( 25, 25 ) ); readMemoryButton->setPaletteBackgroundColor( QColor( 205, 205, 205 ) ); QFont readMemoryButton_font( readMemoryButton->font() ); readMemoryButton_font.setPointSize( 8 ); readMemoryButton->setFont( readMemoryButton_font ); calcFrameLayout->addWidget( readMemoryButton, 2, 0 ); btn_4 = new QPushButton( calcFrame, "btn_4" ); btn_4->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_4->sizePolicy().hasHeightForWidth() ) ); btn_4->setMaximumSize( QSize( 25, 25 ) ); QFont btn_4_font( btn_4->font() ); btn_4_font.setPointSize( 8 ); btn_4->setFont( btn_4_font ); calcFrameLayout->addWidget( btn_4, 2, 1 ); btn_5 = new QPushButton( calcFrame, "btn_5" ); btn_5->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_5->sizePolicy().hasHeightForWidth() ) ); btn_5->setMaximumSize( QSize( 25, 25 ) ); QFont btn_5_font( btn_5->font() ); btn_5_font.setPointSize( 8 ); btn_5->setFont( btn_5_font ); calcFrameLayout->addWidget( btn_5, 2, 2 ); btn_6 = new QPushButton( calcFrame, "btn_6" ); btn_6->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_6->sizePolicy().hasHeightForWidth() ) ); btn_6->setMaximumSize( QSize( 25, 25 ) ); QFont btn_6_font( btn_6->font() ); btn_6_font.setPointSize( 8 ); btn_6->setFont( btn_6_font ); calcFrameLayout->addWidget( btn_6, 2, 3 ); minusButton = new QPushButton( calcFrame, "minusButton" ); minusButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, minusButton->sizePolicy().hasHeightForWidth() ) ); minusButton->setMaximumSize( QSize( 25, 25 ) ); minusButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont minusButton_font( minusButton->font() ); minusButton_font.setPointSize( 8 ); minusButton->setFont( minusButton_font ); calcFrameLayout->addWidget( minusButton, 2, 4 ); persentButton = new QPushButton( calcFrame, "persentButton" ); persentButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, persentButton->sizePolicy().hasHeightForWidth() ) ); persentButton->setMaximumSize( QSize( 25, 25 ) ); persentButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont persentButton_font( persentButton->font() ); persentButton_font.setPointSize( 8 ); persentButton->setFont( persentButton_font ); calcFrameLayout->addWidget( persentButton, 2, 5 ); clearAllButton = new QPushButton( calcFrame, "clearAllButton" ); clearAllButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, clearAllButton->sizePolicy().hasHeightForWidth() ) ); clearAllButton->setMaximumSize( QSize( 25, 25 ) ); clearAllButton->setPaletteBackgroundColor( QColor( 250, 200, 200 ) ); QFont clearAllButton_font( clearAllButton->font() ); clearAllButton_font.setPointSize( 8 ); clearAllButton->setFont( clearAllButton_font ); calcFrameLayout->addWidget( clearAllButton, 2, 6 ); minusMemoryButton = new QPushButton( calcFrame, "minusMemoryButton" ); minusMemoryButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, minusMemoryButton->sizePolicy().hasHeightForWidth() ) ); minusMemoryButton->setMaximumSize( QSize( 25, 25 ) ); minusMemoryButton->setPaletteBackgroundColor( QColor( 205, 205, 205 ) ); QFont minusMemoryButton_font( minusMemoryButton->font() ); minusMemoryButton_font.setPointSize( 8 ); minusMemoryButton->setFont( minusMemoryButton_font ); calcFrameLayout->addWidget( minusMemoryButton, 3, 0 ); btn_1 = new QPushButton( calcFrame, "btn_1" ); btn_1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_1->sizePolicy().hasHeightForWidth() ) ); btn_1->setMaximumSize( QSize( 25, 25 ) ); QFont btn_1_font( btn_1->font() ); btn_1_font.setPointSize( 8 ); btn_1->setFont( btn_1_font ); calcFrameLayout->addWidget( btn_1, 3, 1 ); btn_2 = new QPushButton( calcFrame, "btn_2" ); btn_2->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_2->sizePolicy().hasHeightForWidth() ) ); btn_2->setMaximumSize( QSize( 25, 25 ) ); QFont btn_2_font( btn_2->font() ); btn_2_font.setPointSize( 8 ); btn_2->setFont( btn_2_font ); calcFrameLayout->addWidget( btn_2, 3, 2 ); btn_3 = new QPushButton( calcFrame, "btn_3" ); btn_3->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_3->sizePolicy().hasHeightForWidth() ) ); btn_3->setMaximumSize( QSize( 25, 25 ) ); QFont btn_3_font( btn_3->font() ); btn_3_font.setPointSize( 8 ); btn_3->setFont( btn_3_font ); calcFrameLayout->addWidget( btn_3, 3, 3 ); timesButton = new QPushButton( calcFrame, "timesButton" ); timesButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, timesButton->sizePolicy().hasHeightForWidth() ) ); timesButton->setMaximumSize( QSize( 25, 25 ) ); timesButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont timesButton_font( timesButton->font() ); timesButton_font.setPointSize( 8 ); timesButton->setFont( timesButton_font ); calcFrameLayout->addWidget( timesButton, 3, 4 ); reciprocalButton = new QPushButton( calcFrame, "reciprocalButton" ); reciprocalButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, reciprocalButton->sizePolicy().hasHeightForWidth() ) ); reciprocalButton->setMaximumSize( QSize( 25, 25 ) ); reciprocalButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont reciprocalButton_font( reciprocalButton->font() ); reciprocalButton_font.setPointSize( 8 ); reciprocalButton->setFont( reciprocalButton_font ); calcFrameLayout->addWidget( reciprocalButton, 3, 5 ); backspaceButton = new QPushButton( calcFrame, "backspaceButton" ); backspaceButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, backspaceButton->sizePolicy().hasHeightForWidth() ) ); backspaceButton->setMaximumSize( QSize( 25, 25 ) ); backspaceButton->setPaletteBackgroundColor( QColor( 250, 200, 200 ) ); QFont backspaceButton_font( backspaceButton->font() ); backspaceButton_font.setPointSize( 8 ); backspaceButton->setFont( backspaceButton_font ); calcFrameLayout->addWidget( backspaceButton, 3, 6 ); addToMemoryButton = new QPushButton( calcFrame, "addToMemoryButton" ); addToMemoryButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, addToMemoryButton->sizePolicy().hasHeightForWidth() ) ); addToMemoryButton->setMaximumSize( QSize( 25, 25 ) ); addToMemoryButton->setPaletteBackgroundColor( QColor( 205, 205, 205 ) ); QFont addToMemoryButton_font( addToMemoryButton->font() ); addToMemoryButton_font.setPointSize( 8 ); addToMemoryButton->setFont( addToMemoryButton_font ); calcFrameLayout->addWidget( addToMemoryButton, 4, 0 ); btn_0 = new QPushButton( calcFrame, "btn_0" ); btn_0->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, btn_0->sizePolicy().hasHeightForWidth() ) ); btn_0->setMaximumSize( QSize( 25, 25 ) ); QFont btn_0_font( btn_0->font() ); btn_0_font.setPointSize( 8 ); btn_0->setFont( btn_0_font ); calcFrameLayout->addWidget( btn_0, 4, 1 ); doubleZero = new QPushButton( calcFrame, "doubleZero" ); doubleZero->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, doubleZero->sizePolicy().hasHeightForWidth() ) ); doubleZero->setMaximumSize( QSize( 25, 25 ) ); QFont doubleZero_font( doubleZero->font() ); doubleZero_font.setPointSize( 8 ); doubleZero->setFont( doubleZero_font ); calcFrameLayout->addWidget( doubleZero, 4, 2 ); pointButton = new QPushButton( calcFrame, "pointButton" ); pointButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, pointButton->sizePolicy().hasHeightForWidth() ) ); pointButton->setMaximumSize( QSize( 25, 25 ) ); QFont pointButton_font( pointButton->font() ); pointButton_font.setPointSize( 8 ); pointButton->setFont( pointButton_font ); calcFrameLayout->addWidget( pointButton, 4, 3 ); divisionButton = new QPushButton( calcFrame, "divisionButton" ); divisionButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, divisionButton->sizePolicy().hasHeightForWidth() ) ); divisionButton->setMaximumSize( QSize( 25, 25 ) ); divisionButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont divisionButton_font( divisionButton->font() ); divisionButton_font.setPointSize( 8 ); divisionButton->setFont( divisionButton_font ); calcFrameLayout->addWidget( divisionButton, 4, 4 ); powButton = new QPushButton( calcFrame, "powButton" ); powButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, powButton->sizePolicy().hasHeightForWidth() ) ); powButton->setMaximumSize( QSize( 25, 25 ) ); powButton->setPaletteBackgroundColor( QColor( 200, 250, 200 ) ); QFont powButton_font( powButton->font() ); powButton_font.setPointSize( 8 ); powButton->setFont( powButton_font ); calcFrameLayout->addWidget( powButton, 4, 5 ); equalButton = new QPushButton( calcFrame, "equalButton" ); equalButton->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, equalButton->sizePolicy().hasHeightForWidth() ) ); equalButton->setMaximumSize( QSize( 25, 25 ) ); equalButton->setPaletteBackgroundColor( QColor( 200, 200, 250 ) ); QFont equalButton_font( equalButton->font() ); equalButton_font.setPointSize( 8 ); equalButton->setFont( equalButton_font ); calcFrameLayout->addWidget( equalButton, 4, 6 ); MiniCalcLayout->addWidget( calcFrame, 0, 0 ); extension = new QFrame( this, "extension" ); extension->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, extension->sizePolicy().hasHeightForWidth() ) ); extension->setFrameShape( QFrame::StyledPanel ); extension->setFrameShadow( QFrame::Raised ); extensionLayout = new QGridLayout( extension, 1, 1, 1, 1, "extensionLayout"); label = new QLabel( extension, "label" ); label->setMinimumSize( QSize( 0, 20 ) ); QFont label_font( label->font() ); label_font.setPointSize( 8 ); label->setFont( label_font ); //label->setAlignment( int( QLabel::AlignCenter ) ); extensionLayout->addMultiCellWidget( label, 0, 0, 0, 2 ); mem_1 = new QLineEdit( extension, "mem_1" ); QFont mem_1_font( mem_1->font() ); mem_1_font.setPointSize( 10 ); mem_1->setFont( mem_1_font ); extensionLayout->addWidget( mem_1, 1, 2 ); mem_to_disp_4 = new QPushButton( extension, "mtd_4" ); mem_to_disp_4->setMaximumSize( QSize( 25, 25 ) ); QFont mem_to_disp_4_font( mem_to_disp_4->font() ); mem_to_disp_4_font.setPointSize( 8 ); mem_to_disp_4->setFont( mem_to_disp_4_font ); extensionLayout->addWidget( mem_to_disp_4, 4, 1 ); disp_to_mem_4 = new QPushButton( extension, "dtm_4" ); disp_to_mem_4->setMaximumSize( QSize( 25, 25 ) ); QFont disp_to_mem_4_font( disp_to_mem_4->font() ); disp_to_mem_4_font.setPointSize( 8 ); disp_to_mem_4->setFont( disp_to_mem_4_font ); extensionLayout->addWidget( disp_to_mem_4, 4, 0 ); mem_to_disp_3 = new QPushButton( extension, "mtd_3" ); mem_to_disp_3->setMaximumSize( QSize( 25, 25 ) ); QFont mem_to_disp_3_font( mem_to_disp_3->font() ); mem_to_disp_3_font.setPointSize( 8 ); mem_to_disp_3->setFont( mem_to_disp_3_font ); extensionLayout->addWidget( mem_to_disp_3, 3, 1 ); disp_to_mem_3 = new QPushButton( extension, "dtm_3" ); disp_to_mem_3->setMaximumSize( QSize( 25, 25 ) ); QFont disp_to_mem_3_font( disp_to_mem_3->font() ); disp_to_mem_3_font.setPointSize( 8 ); disp_to_mem_3->setFont( disp_to_mem_3_font ); extensionLayout->addWidget( disp_to_mem_3, 3, 0 ); disp_to_mem_1 = new QPushButton( extension, "dtm_1" ); disp_to_mem_1->setMaximumSize( QSize( 25, 25 ) ); QFont disp_to_mem_1_font( disp_to_mem_1->font() ); disp_to_mem_1_font.setPointSize( 8 ); disp_to_mem_1->setFont( disp_to_mem_1_font ); extensionLayout->addWidget( disp_to_mem_1, 1, 0 ); mem_4 = new QLineEdit( extension, "mem_4" ); QFont mem_4_font( mem_4->font() ); mem_4_font.setPointSize( 10 ); mem_4->setFont( mem_4_font ); extensionLayout->addWidget( mem_4, 4, 2 ); mem_3 = new QLineEdit( extension, "mem_3" ); QFont mem_3_font( mem_3->font() ); mem_3_font.setPointSize( 10 ); mem_3->setFont( mem_3_font ); extensionLayout->addWidget( mem_3, 3, 2 ); disp_to_mem_2 = new QPushButton( extension, "dtm_2" ); disp_to_mem_2->setMaximumSize( QSize( 25, 25 ) ); QFont disp_to_mem_2_font( disp_to_mem_2->font() ); disp_to_mem_2_font.setPointSize( 8 ); disp_to_mem_2->setFont( disp_to_mem_2_font ); extensionLayout->addWidget( disp_to_mem_2, 2, 0 ); mem_2 = new QLineEdit( extension, "mem_2" ); QFont mem_2_font( mem_2->font() ); mem_2_font.setPointSize( 10 ); mem_2->setFont( mem_2_font ); extensionLayout->addWidget( mem_2, 2, 2 ); mem_to_disp_2 = new QPushButton( extension, "mtd_2" ); mem_to_disp_2->setMaximumSize( QSize( 25, 25 ) ); QFont mem_to_disp_2_font( mem_to_disp_2->font() ); mem_to_disp_2_font.setPointSize( 8 ); mem_to_disp_2->setFont( mem_to_disp_2_font ); extensionLayout->addWidget( mem_to_disp_2, 2, 1 ); mem_to_disp_1 = new QPushButton( extension, "mtd_1" ); mem_to_disp_1->setMaximumSize( QSize( 25, 25 ) ); QFont mem_to_disp_1_font( mem_to_disp_1->font() ); mem_to_disp_1_font.setPointSize( 8 ); mem_to_disp_1->setFont( mem_to_disp_1_font ); extensionLayout->addWidget( mem_to_disp_1, 1, 1 ); MiniCalcLayout->addWidget( extension, 1, 0 ); languageChange(); resize( QSize(210, 233).expandedTo(minimumSizeHint()) ); clearWState( WState_Polished ); extension->hide(); clearMemoryButton->setDisabled(true); readMemoryButton->setDisabled(true); // signals and slots connections connect( extMem, SIGNAL( clicked() ), this, SLOT( extMemClicked() ) ); connect( btn_0, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_1, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_2, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_3, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_4, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_5, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_6, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_7, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_8, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( btn_9, SIGNAL( clicked() ), this, SLOT( digitClicked() ) ); connect( mem_to_disp_1, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( mem_to_disp_2, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( mem_to_disp_3, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( mem_to_disp_4, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( disp_to_mem_1, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( disp_to_mem_2, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( disp_to_mem_3, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( disp_to_mem_4, SIGNAL( clicked() ), this, SLOT(extMemOperations())); connect( backspaceButton, SIGNAL( clicked() ), this, SLOT(backspaceClicked())); connect( changeSignButton, SIGNAL( clicked() ), this, SLOT(changeSignClicked())); connect( reciprocalButton, SIGNAL( clicked() ), this, SLOT( unaryOperatorClicked() ) ); connect( powButton, SIGNAL( clicked() ), this, SLOT( unaryOperatorClicked() ) ); connect( divisionButton, SIGNAL( clicked() ), this, SLOT( multiplicativeOperatorClicked() ) ); connect( timesButton, SIGNAL( clicked() ), this, SLOT( multiplicativeOperatorClicked() ) ); connect( minusButton, SIGNAL( clicked() ), this, SLOT( additiveOperatorClicked() ) ); connect( plusButton, SIGNAL( clicked() ), this, SLOT( additiveOperatorClicked() ) ); connect( persentButton, SIGNAL( clicked() ), this, SLOT( percentClicked() ) ); connect( equalButton, SIGNAL( clicked() ), this, SLOT( equalClicked() ) ); connect( doubleZero, SIGNAL( clicked() ), this, SLOT( dzClicked() ) ); connect( pointButton, SIGNAL( clicked() ), this, SLOT( pointClicked() ) ); connect( clearButton, SIGNAL( clicked() ), this, SLOT( clear() ) ); connect( clearAllButton, SIGNAL( clicked() ), this, SLOT( clearAll() ) ); connect( clearMemoryButton, SIGNAL( clicked() ), this, SLOT( clearMemory() ) ); connect( toDocButton, SIGNAL( clicked() ), this, SLOT( toDoc() ) ); connect( clearMemoryButton, SIGNAL( clicked() ), this, SLOT( clearMemory() ) ); connect( readMemoryButton, SIGNAL( clicked() ), this, SLOT( readMemory() ) ); connect( minusMemoryButton, SIGNAL( clicked() ), this, SLOT( minusMemory() ) ); connect( addToMemoryButton, SIGNAL( clicked() ), this, SLOT( addToMemory() ) ); }