Hi,
I get No Errors now...But if i click my ComboBox my Function "selectSprache()" will not be called, Can somebody see why?
#include "test.h"
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QTextEdit>
#include <QStatusBar>
#include <QAbstractItemView>
#include <QEvent>
MainWindow::MainWindow()
{
ui.setupUi(this);
installEventFilter(ui.sprache_cb->view());
connect(ui.actionverbinden, SIGNAL(triggered()), this, SLOT(verbinden()));
connect(ui.speichern_btn, SIGNAL(clicked()), this, SLOT(selectSprache()));
}
bool MainWindow::verbinden()
{
db.setHostName("pcpsr5");
db.setDatabaseName("DRIVER={SQL Server};SERVER=pcpsr5;DATABASE=inventar;UID=sa;PWD=");
db.setUserName("sa");
db.setPassword("");
if(!db.open())
{
QMessageBox::information(this,
"",db.
lastError().
text());
return false;
}
else
return true;
}
void MainWindow::selectSprache()
{
/*
QSqlQuery select (" select sprache from sprache_tbl");
while(select.next())
{
QString sprachen = select.value(0).toString();
ui.sprache_te->insertPlainText(sprachen + " ");
}
*/
}
{
if ( e
->type
() == QEvent::Show ) {
selectSprache();
return TRUE;
}
else
return FALSE;
}
#include "test.h"
#include <QMessageBox>
#include <QSqlDatabase>
#include <QSqlQuery>
#include <QSqlError>
#include <QTextEdit>
#include <QStatusBar>
#include <QAbstractItemView>
#include <QEvent>
MainWindow::MainWindow()
{
ui.setupUi(this);
installEventFilter(ui.sprache_cb->view());
connect(ui.actionverbinden, SIGNAL(triggered()), this, SLOT(verbinden()));
connect(ui.speichern_btn, SIGNAL(clicked()), this, SLOT(selectSprache()));
}
bool MainWindow::verbinden()
{
QSqlDatabase db = QSqlDatabase::addDatabase("QODBC");
db.setHostName("pcpsr5");
db.setDatabaseName("DRIVER={SQL Server};SERVER=pcpsr5;DATABASE=inventar;UID=sa;PWD=");
db.setUserName("sa");
db.setPassword("");
if(!db.open())
{
QMessageBox::information(this,"",db.lastError().text());
return false;
}
else
return true;
}
void MainWindow::selectSprache()
{
/*
QSqlQuery select (" select sprache from sprache_tbl");
while(select.next())
{
QString sprachen = select.value(0).toString();
ui.sprache_te->insertPlainText(sprachen + " ");
}
*/
QMessageBox::information(this,"","");
}
bool MainWindow::eventFilter( QObject *o, QEvent *e )
{
if ( e->type() == QEvent::Show )
{
selectSprache();
return TRUE;
}
else
return FALSE;
}
To copy to clipboard, switch view to plain text mode
#include "ui_mainwindow.h"
{
Q_OBJECT
public:
MainWindow();
public slots:
bool verbinden();
void selectSprache();
private:
Ui::MainWindow ui;
protected:
};
#include "ui_mainwindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow();
QStatusBar *statusbar;
public slots:
bool verbinden();
void selectSprache();
private:
Ui::MainWindow ui;
protected:
bool eventFilter( QObject *o, QEvent *e );
};
To copy to clipboard, switch view to plain text mode
Bookmarks