Hello,
I'm creating my first app with my own slot .
I'm trying to program an app able to manage salaries and payment
in certain phase of the code I need to use the value choosed in the
QComboBox "CB01" to window "Win2" in order to modify some data
But I don't know how to transmit the value in "CB01" to the function
"MSte()" in "Win2"
but the way I'm using Qt4.8 with ubuntu 12.04
and this is the code
MainWin.cpp
Code:
#include "MainWin.h" #include "Win1.h" #include "Win2.h" #include "Win3.h" MainWin::MainWin() { //Societé HB01->addWidget(PB01); HB01->addWidget(PB02); HB01->addWidget(PB03); VB01->addWidget(LAB01); VB01->addWidget(CB01); VB01->addLayout(HB01); VB01->addWidget(PB04); //Employés HB02->addWidget(PB05); HB02->addWidget(PB06); HB02->addWidget(PB07); VB02->addWidget(LAB02); VB02->addWidget(CB02); VB02->addLayout(HB02); VB02->addWidget(PB08); //Definition du titre de la fenetre MW->addLayout(VB01); MW->addLayout(VB02); setLayout(MW); setWindowTitle("Easy Paie"); resize(400,250); //Connextions des signaux et des slots connect(PB01,SIGNAL(clicked()),this,SLOT(AddSte())); connect(PB02,SIGNAL(clicked()),this,SLOT(ModSte(CB01))); connect(PB03,SIGNAL(clicked()),this,SLOT(DelSte())); } void MainWin::AddSte() { Win1 *win1=new Win1(); win1->show(); } { Win2 *win2(CB01)=new Win2(); win2.show(); }
MainWin.h
Code:
#ifndef MAINWIN_H #define MAINWIN_H #include <QtGui> { Q_OBJECT public: MainWin(); private slots: void AddSte(); void DelSte(); private: QComboBox *CB01; QComboBox *CB02; QPushButton *PB01; QPushButton *PB02; QPushButton *PB03; QPushButton *PB04; QPushButton *PB05; QPushButton *PB06; QPushButton *PB07; QPushButton *PB08; }; #endif // MAINWIN_H
Win2.cpp
Code:
#include "Win2.h" #include <fstream> #include <string> #include <QString> using namespace std; Win2::Win2() { HB21->addWidget(PB21); HB21->addWidget(PB22); VB21->addWidget(LAB21); VB21->addWidget(LE21); VB21->addWidget(LAB22); VB21->addWidget(LE22); VB21->addLayout(HB21); setLayout(VB21); setWindowTitle("Modifier"); //connect connect(PB21,SIGNAL(clicked()),this,SLOT(close())); connect(PB22,SIGNAL(clicked()),this,SLOT(MSte(CB01))); } { string s1,s2,ss,ch; QString ste,cnss; ste=LE21->text(); cnss=LE22->text(); s1=ste.toStdString(); s2=cnss.toStdString(); ss=s2+' '+s1; ofstream NS("NSTE"); ifstream S("STE"); while(!S.eof()) { S>>ch; if(ch==ss) NS<<"FUCK"<<endl; else NS<<ch<<endl; } S.close(); NS.close(); close(); }
Win2.h
Code:
#ifndef WIN2_H #define WIN2_H #include <QtGui> { Q_OBJECT public: private slots: private: QLineEdit *LE21; QLineEdit *LE22; QPushButton *PB21; QPushButton *PB22; }; #endif // WIN2_H
And thank you
:cool: