hi, i got this at app output...
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
no error while i try to build my program...its shows that after i build.. but
what it means?
Printable View
hi, i got this at app output...
QObject::installEventFilter(): Cannot filter events for objects in a different thread.
no error while i try to build my program...its shows that after i build.. but
what it means?
You are probably trying to install filter on some object, which is part of another thread..
If you show the code, may be we can tell better
well i dont understand what it means..huhuh
now i try write database using progrmmg..
this my mainwindow.h
Code:
#ifndef MAINWINDOW_H #define MAINWINDOW_H #include <QMainWindow> #include <QWidget> class QComboBox; class QDataWidgetMapper; class QItemSelectionModel; class QLabel; class QLineEdit; class QPushButton; class QSqlRelationalTableModel; class QStandardItemModel; class QStringListModel; class QTextEdit; Q_OBJECT public: private slots: void updateButton(int row); private: void setupModel(); QLabel *label; QTextEdit *textEdit; QComboBox *comboBox; QPushButton *pushButton; QSqlRelationalTableModel *model; QItemSelectionModel *selectionModel; QDataWidgetMapper *mapper; }; #endif // MAINWINDOW_H
mainwindow.cpp
Code:
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QSqlTableModel> #include <QDataWidgetMapper> #include <QSqlRelationalDelegate> #include <QSqlRelationalTableModel> #include <QMessageBox> #include <QSqlQuery> { setupModel(); mapper->setModel(model); mapper->addMapping(comboBox, model->fieldIndex("name")); mapper->addMapping(textEdit, model->fieldIndex("address")); connect(pushButton, SIGNAL(clicked()), mapper, SLOT(updateButton(int))); setWindowTitle(tr("WiseAviation")); mapper->toFirst(); } void MainWindow::setupModel() { db.setHostName("localhost"); db.setDatabaseName("wiseavi"); db.setUserName("root"); db.setPassword("root"); if (!db.open()) { tr("Unable to establish a database connection.\n" "This example needs SQMySQL support. Please read " "the Qt SQL driver documentation for information how " return; } QSqlQuery query; query.exec("create table workers (name varchar(20), address varchar(200)"); query.exec("insert into workers values( 'Siti', " "'Sabah')"); query.exec("insert into workers values( 'Atun', " "'Perak')"); query.exec("insert into workers values( 'fifa', " "'kedah')"); model->setTable("workers"); model->select(); } void MainWindow::updateButton(int row) { pushButton->update(); }
main.cpp
Code:
#include <QtGui/QApplication> #include "mainwindow.h" int main(int argc, char *argv[]) { MainWindow w; w.show(); return a.exec(); }
This is probably not going to solve your problem, but it's an error nontheless.
This is wrong for at least two reasons:Quote:
Code:
connect(pushButton, SIGNAL(clicked()), mapper, SLOT(updateButton(int)));
1. slots can not have more parameters than signals
2. mapper doesn't contain a slot called updateButton(int)
Am not sure where the installEventFilter code is coming from.
But my guess is mapper->setItemDelegate(new QSqlRelationalDelegate(this));
this is QMainWindow, and you need to assign a view(QTableView) to the delegate.
And you havent created a view !!
i still don't understand..
i use textedit to view ..
could u please to give some code or example to show my data on table?