Code:
#include <qapplication.h>
#include <qapplication.h>
#include <qpushbutton.h>
#include <qfont.h>
#include <qlineedit.h>
#include <qlabel.h>
#include <qcombobox.h>
#include <qtextedit.h>
#include <qsqldriver.h>
#include <qsqldatabase.h>
#define DB_ADRESS_DRIVER "QMYSQL3"
#define DB_ADRESS_DBNAME "stundenplan"
#define DB_ADRESS_USER "xxxx"
#define DB_ADRESS_PASSWD "xxxxx"
#define DB_ADRESS_HOST "wodan"
class Hausaufgabe: public QObject
{
Q_OBJECT
public slots:
signals:
private:
char *username;
char *password;
char *dateiname;
char *titel;
char *nachricht;
public:
void SetUsername(char *user);
void SetPassword(char *pw);
void SetDateiname(char *filename);
void SetTitle(char *text);
void SetNachricht(char *text);
};
class MyWidget : public QWidget
{
Q_OBJECT
public slots:
void handleActivated( int Schiene);
public:
MyWidget( QWidget *parent=0, const char *name=0 );
};
MyWidget::MyWidget( QWidget *parent, const char *name )
: QWidget( parent, name )
{
setMinimumSize( 400, 600 );
setMaximumSize( 400, 600 );
QLabel *lbUsername = new QLabel(this);
QLabel *lbPassword = new QLabel(this);
QLineEdit *username = new QLineEdit("", this, "username");
QLineEdit *password = new QLineEdit("", this, "password");
QLineEdit *filename = new QLineEdit("", this, "filename");
QPushButton *quit = new QPushButton( "Beenden", this, "quit" );
QPushButton *login=new QPushButton("Einloggen",this,"login");
QPushButton *datei=new QPushButton(". . .", this, "datei");
QPushButton *upload=new QPushButton("Hochladen", this, "upload");
QComboBox *GK = new QComboBox( FALSE, this, "GK" );
QComboBox *Fach = new QComboBox( FALSE, this, "Fach" );
QTextEdit *Nachricht = new QTextEdit (this, "Nachricht");
quit->setFont( QFont( "Arial", 10 ) );
quit->setGeometry(320, 565, 75, 30 );
login->setFont(QFont("Arial,10"));
login->setGeometry(320,45,75,25);
lbUsername->setText ( "Benutzername:");
lbUsername->setGeometry(5,10,100,25);
lbUsername->setFont( QFont("Arial",10));
lbPassword->setText("Passwort:");
lbPassword->setFont(QFont("Arial",10));
lbPassword->setGeometry(210,10,70,25);
username->setFont(QFont("Arial",10));
username->setGeometry(105,10,100,25);
password->setFont(QFont("Arial",10));
password->setGeometry(285,10,100,25);
password->setEchoMode(QLineEdit::Password);
GK->setFont(QFont("Arial",10));
GK->setGeometry(105, 80, 100, 25);
GK->insertItem("LK 1",-1);
GK->insertItem("LK 2",-1);
GK->insertItem("GK 1",-1);
GK->insertItem("GK 2",-1);
GK->insertItem("GK 3",-1);
GK->insertItem("GK 4",-1);
GK->insertItem("GK 5",-1);
GK->insertItem("GK 6",-1);
GK->insertItem("GK 7",-1);
GK->insertItem("GK 8",-1);
Fach->setFont(QFont("Arial",10));
Fach->setGeometry(285, 80, 100, 25);
Nachricht->setFont(QFont("Arial",10));
Nachricht->setGeometry(5, 115, 390,350);
filename->setFont(QFont("Arial",10));
filename->setGeometry(5,475,355,25);
datei->setFont(QFont("Arial",10));
datei->setGeometry( 365,475,30,25);
upload->setFont(QFont("Arial",10));
upload->setGeometry(150,510,100,50);
connect( quit, SIGNAL(clicked()), qApp, SLOT(quit()) );
connect ( GK, SIGNAL(activated(index)), qApp, SLOT(handleActivated(index)));
}
void MyWidget::handleActivated( int Schiene)
{
Schiene=1;
qWarning( "test" );
}
int main( int argc, char **argv )
{
QApplication a( argc, argv );
MyWidget w;
w.setGeometry( 100, 100, 200, 120 );
a.setMainWidget( &w );
w.show();
QSqlDatabase *defaultDB = QSqlDatabase::addDatabase( DB_ADRESS_DRIVER );
if ( ! defaultDB )
{
qWarning( "main: Keine Verbindung zur Datenbank" );
return 1;
}
return a.exec();
}
#include "main.moc"
dann krieg ich das programm auch so kompiliert:
Lesezeichen