Hello!
First at all, my english is really really bad, sorry for this :c

Well, I maked a program, with a lineedit, this lineedit is for filtering the database

the database is a .sqlite file

The database was edited in navicat for sqlite

My SO is Windows XP SP 3 and my qt version is QT 5.0.2, but i tried this code in 5.2.1 and 5.3.2 and doesn't work ...
and the compiler is Minwg 4.7 , but i tried with 4.8 and 4.8.2

this is my dialog.h
Qt Code:
  1. #ifndef DIALOG_H
  2. #define DIALOG_H
  3.  
  4. #include <QDialog>
  5. #include <QSqlRelationalTableModel>
  6. #include <QSortFilterProxyModel>
  7. #include <cn.h>
  8.  
  9. namespace Ui {
  10. class Dialog;
  11. }
  12.  
  13. class Dialog : public QDialog
  14. {
  15. Q_OBJECT
  16.  
  17. public:
  18. explicit Dialog(QWidget *parent = 0);
  19. ~Dialog();
  20. QSqlRelationalTableModel * modPersonas;
  21. QSortFilterProxyModel * proxyPersonas;
  22.  
  23.  
  24. private slots:
  25. void on_lineEdit_textChanged(const QString &arg1);
  26.  
  27. private:
  28. Ui::Dialog *ui;
  29. };
  30.  
  31. #endif // DIALOG_H
To copy to clipboard, switch view to plain text mode 

my cn.h (where i declare the database pointers)
Qt Code:
  1. #ifndef CN_H
  2. #define CN_H
  3.  
  4. #include <QObject>
  5. #include <QSqlDatabase>
  6.  
  7. class cn : public QObject
  8. {
  9. Q_OBJECT
  10. public:
  11. explicit cn(QObject *parent = 0);
  12.  
  13. static cn *_obj;
  14. static cn *obj();
  15.  
  16. static QSqlDatabase _db;
  17. static QSqlDatabase db();
  18.  
  19. signals:
  20.  
  21. public slots:
  22.  
  23. };
  24.  
  25. #endif // CN_H
To copy to clipboard, switch view to plain text mode 

my cn.cpp(this create the database(next i edit this database with navicat))
Qt Code:
  1. #include "cn.h"
  2. #include "QDir"
  3. #include <QDebug>
  4.  
  5.  
  6. QSqlDatabase cn::_db = QSqlDatabase::addDatabase("QSQLITE");
  7. cn *cn::_obj = new cn;
  8.  
  9. cn::cn(QObject *parent) :
  10. QObject(parent)
  11. {
  12. _db.setDatabaseName(QDir::currentPath() + "/TutorilDb.sqlite");
  13. if(_db.open()){
  14. qDebug() << "Conexión a la base de datos exitosa =>" + _db.databaseName() + "<=";
  15. }
  16. else{
  17. qDebug() << "Problemas para ejecutar la base de datos" + _db.databaseName();
  18. }
  19. }
  20.  
  21. cn *cn::obj()
  22. {
  23. if(!_obj){
  24. _obj = new cn();
  25. }
  26. return _obj;
  27. }
  28.  
  29. QSqlDatabase cn::db()
  30. {
  31. return _db;
  32. }
To copy to clipboard, switch view to plain text mode 

my dialog.cpp
Qt Code:
  1. #include "dialog.h"
  2. #include "ui_dialog.h"
  3.  
  4. Dialog::Dialog(QWidget *parent) :
  5. QDialog(parent),
  6. ui(new Ui::Dialog)
  7. {
  8. ui->setupUi(this);
  9. //traemos los datos a la tabla, estamos en el constructor
  10. modPersonas = new QSqlRelationalTableModel(this, cn::db());
  11. modPersonas->setTable("tbPersonas");
  12. modPersonas->setRelation(modPersonas->fieldIndex("tipo"), QSqlRelation("tbTipo", "id", "tipo"));
  13. modPersonas->select();
  14.  
  15. //filtro de busquedas
  16. proxyPersonas = new QSortFilterProxyModel(this);
  17. proxyPersonas->setSourceModel(modPersonas);
  18. proxyPersonas->setFilterCaseSensitivity(Qt::CaseInsensitive);
  19. proxyPersonas->setFilterKeyColumn(-1);
  20.  
  21. ui->cbCol->addItems(QStringList() << "Id" << "Nombre" << "Apellido");
  22.  
  23. ui->tableView->setModel(modPersonas);
  24. }
  25.  
  26. Dialog::~Dialog()
  27. {
  28. delete ui;
  29. }
  30.  
  31. void Dialog::on_lineEdit_textChanged(const QString &arg1)
  32. {
  33. proxyPersonas->setFilterFixedString(arg1);
  34. }
To copy to clipboard, switch view to plain text mode 

well, here is my problem, this compile good, but, when i write in the line edit, this doesnt filter, and i don't know why
Qt Code:
  1. void Dialog::on_lineEdit_textChanged(const QString &arg1)
  2. {
  3. proxyPersonas->setFilterFixedString(arg1);
  4. }
To copy to clipboard, switch view to plain text mode 

If you know what im doing bad, i'll be very grateful

Thanks c:

ps: sorry for spanish text in the code, i use this for know what does each part (que hace cada parte, i dont know if a translate correctly this XD)