RolandHughes
13th November 2008, 22:12
Hello,
64-bit Ubuntu 8.10 (version of Qt and C++ that came with distro)
8.3.4 PostgreSQL
Table layout as follows:
CREATE TABLE expenses (
-- tran_id serial not null primary key,
tran_dt date,
category char(25) CONSTRAINT valid_cat REFERENCES categories (category) MATCH FULL ON DELETE RESTRICT,
tax_ded boolean,
payee char(50) CONSTRAINT valid_payee REFERENCES payees (payee) MATCH FULL ON DELETE RESTRICT,
amount numeric(10,2) CONSTRAINT amt_constraint NOT NULL);
here are some snippets for the mapping
tax_dedComboBox = new QComboBox;
tax_dedComboBox->addItem( "true");
tax_dedComboBox->addItem( "false");
tax_dedLabel = new QLabel(tr("Ta&x_Ded:"));
tax_dedLabel->setBuddy(tax_dedComboBox);
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
mapper->setModel(tableModel);
mapper->setItemDelegate(new QSqlRelationalDelegate(this));
mapper->addMapping(tran_dtDateEdit, tableModel->fieldIndex("tran_dt"));
mapper->addMapping(categoryComboBox, tableModel->fieldIndex("category"));
mapper->addMapping(tax_dedComboBox, tableModel->fieldIndex("tax_ded"));
mapper->addMapping(payeeComboBox, tableModel->fieldIndex("payee"));
mapper->addMapping(amountLineEdit, tableModel->fieldIndex("amount"));
The combobox has to have the values "true" and "false" since that is the way the mapper seems to return them. It does not translate values correctly when performing inserts, but will correctly set the combobox value if the boolean exists in the database.
64-bit Ubuntu 8.10 (version of Qt and C++ that came with distro)
8.3.4 PostgreSQL
Table layout as follows:
CREATE TABLE expenses (
-- tran_id serial not null primary key,
tran_dt date,
category char(25) CONSTRAINT valid_cat REFERENCES categories (category) MATCH FULL ON DELETE RESTRICT,
tax_ded boolean,
payee char(50) CONSTRAINT valid_payee REFERENCES payees (payee) MATCH FULL ON DELETE RESTRICT,
amount numeric(10,2) CONSTRAINT amt_constraint NOT NULL);
here are some snippets for the mapping
tax_dedComboBox = new QComboBox;
tax_dedComboBox->addItem( "true");
tax_dedComboBox->addItem( "false");
tax_dedLabel = new QLabel(tr("Ta&x_Ded:"));
tax_dedLabel->setBuddy(tax_dedComboBox);
mapper = new QDataWidgetMapper(this);
mapper->setSubmitPolicy(QDataWidgetMapper::AutoSubmit);
mapper->setModel(tableModel);
mapper->setItemDelegate(new QSqlRelationalDelegate(this));
mapper->addMapping(tran_dtDateEdit, tableModel->fieldIndex("tran_dt"));
mapper->addMapping(categoryComboBox, tableModel->fieldIndex("category"));
mapper->addMapping(tax_dedComboBox, tableModel->fieldIndex("tax_ded"));
mapper->addMapping(payeeComboBox, tableModel->fieldIndex("payee"));
mapper->addMapping(amountLineEdit, tableModel->fieldIndex("amount"));
The combobox has to have the values "true" and "false" since that is the way the mapper seems to return them. It does not translate values correctly when performing inserts, but will correctly set the combobox value if the boolean exists in the database.