nnidza
3rd January 2007, 15:04
I am using a QT4.1.4 with the PSQL8.1.
Sorry for reposting this problem but I am having problems with the setFilter
method. I saw a plenty of posts in the forum but I just can't make it
work?!
Here is what I have in the constructor:
filt::filt( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
//I have created a form with two buttons OK, CANCEL and a
//table View named by default tableView. In the class I have
//defined a model as a QSqlTableModel.
setupUi(this);
model = new QSqlTableModel(this);
model->setTable("Krv");
model->setFilter("GrupaID = 1");
model->select();
tableView->setModel(model);
tableView->setVisible(true);
}
I have tried
model->setFilter("GrupaID = /"1/""); -< for strings
model->setFilter("Grupa = /"A+/"");
model->setFilter("Grupa = 'A+'");
I tried using a QString in the brackets, but...
When I build my project I get a form with no data?!
When I remove the setFilter line I got the data filled in the
tableView. I tried all sort of filtering (I used it on numbers, int4,
strings, with other tables but i am missing something).
I tried almost all posts in forums but as I said i am missing
something obviously...
Here is a table structure:
CREATE TABLE "Krv"
(
"GrupaID" int8 NOT NULL DEFAULT nextval('redni'::regclass),
"Grupa" varchar(3),
CONSTRAINT "Krv_pkey" PRIMARY KEY ("GrupaID")
)
WITHOUT OIDS;
ALTER TABLE "Krv" OWNER TO postgres;
And here is some table data:
"6";"A-"
"7";"A+"
"8";"B-"
"9";"B+"
"10";"AB+"
"11";"AB-"
"12";"O-"
"13";"O+"
Sorry for reposting this problem but I am having problems with the setFilter
method. I saw a plenty of posts in the forum but I just can't make it
work?!
Here is what I have in the constructor:
filt::filt( QWidget * parent, Qt::WFlags f)
: QDialog(parent, f)
{
//I have created a form with two buttons OK, CANCEL and a
//table View named by default tableView. In the class I have
//defined a model as a QSqlTableModel.
setupUi(this);
model = new QSqlTableModel(this);
model->setTable("Krv");
model->setFilter("GrupaID = 1");
model->select();
tableView->setModel(model);
tableView->setVisible(true);
}
I have tried
model->setFilter("GrupaID = /"1/""); -< for strings
model->setFilter("Grupa = /"A+/"");
model->setFilter("Grupa = 'A+'");
I tried using a QString in the brackets, but...
When I build my project I get a form with no data?!
When I remove the setFilter line I got the data filled in the
tableView. I tried all sort of filtering (I used it on numbers, int4,
strings, with other tables but i am missing something).
I tried almost all posts in forums but as I said i am missing
something obviously...
Here is a table structure:
CREATE TABLE "Krv"
(
"GrupaID" int8 NOT NULL DEFAULT nextval('redni'::regclass),
"Grupa" varchar(3),
CONSTRAINT "Krv_pkey" PRIMARY KEY ("GrupaID")
)
WITHOUT OIDS;
ALTER TABLE "Krv" OWNER TO postgres;
And here is some table data:
"6";"A-"
"7";"A+"
"8";"B-"
"9";"B+"
"10";"AB+"
"11";"AB-"
"12";"O-"
"13";"O+"