PDA

View Full Version : QDataTable problem



ederbs
7th February 2007, 01:35
Friends,

I am again with problems in the "QDataTable". Now the problem is for
commanding the things, in the truth I does not want that it commands
the values, plus all time that is effected a modifies in the date and
hour it commands itself, and I do not want this.

I already tried

dataTable->setSorting(false);

they see here:

http://200.193.29.195/qt3/table.png

when I bring up to date the hour and dates it commands for top.

edm.

wysota
7th February 2007, 03:42
Could you further explain the situation? You don't like the order of items or is it something different?

ederbs
7th February 2007, 15:54
This,

"I do not want to make ordinances in the QDataTable", however when I have "2 ids" equal, as in link above, it effects the ordinance.

In the truth I do not want that he makes no type of ordinance.

wysota
7th February 2007, 16:33
I'm sorry but I don't understand what you want.

ederbs
7th February 2007, 23:42
wysota, excuses for my english.

What it is occurring is that the "QDataTable" order the hour and date for top, then all time that I bring up to date a register, it is effecting the ordinance.

I does not want that it makes this.

http://200.193.29.195/qt3/qdatatable.png

edm.

jacek
7th February 2007, 23:58
The rows will be always ordered in some way. If you want a different order, just sort then using other columns.

ederbs
8th February 2007, 00:08
Hi Jacek,

But I don't understand what you it wanted to say. I simply want that the "QDataTable" does not effect sorting.

edm

wysota
8th February 2007, 00:15
By default the datatable doesn't do any sorting. Maybe it's SQL that sorts your data?

jacek
8th February 2007, 00:16
But I don't understand what you it wanted to say. I simply want that the "QDataTable" does not effect sorting.
What I wanted to say it that if you won't sort your rows in QDataTable, they will have some random order which you can't control (actually it's the order in which database retrieves them).

ederbs
8th February 2007, 01:55
I am not making ORDER BY in Query SQL.

ederbs
8th February 2007, 02:00
Code:

/***************************************/
....

/* Execute Query from dataTable */
QString sqlAcompanhamento = QString("SELECT ....");
cur = new QSqlSelectCursor( sqlAcompanhamento );

/* Show Fields */
dataTable->addColumn("id_ocorrencia", tr("Nº Ocor"), 70);
dataTable->addColumn("nm_bairro_prv", tr("Logradouro"), 190);
dataTable->addColumn("id_viatura", tr("VTR"), 85);
dataTable->addColumn("tm_ocorrencia", tr("HIO"), 90);
dataTable->addColumn("dt_tm_empenho", tr("HEM"), 180);
dataTable->addColumn("dt_tm_chg_ocor", tr("HCO"), 180);
dataTable->addColumn("dt_tm_sai_ocor", tr("HSO"), 180);
dataTable->addColumn("dt_tm_chg_inter", tr("HCLI"), 180);
dataTable->addColumn("dt_tm_sai_inter", tr("HSLI"), 180);

/* Ajust Columns */
dataTable->adjustColumn(0);
dataTable->adjustColumn(1);
dataTable->adjustColumn(2);
dataTable->adjustColumn(3);
dataTable->adjustColumn(4);
dataTable->adjustColumn(5);
dataTable->adjustColumn(6);
dataTable->adjustColumn(7);
dataTable->adjustColumn(8);
dataTable->adjustColumn(9);

/* Mode DataTable */
dataTable->setSqlCursor( cur, false, true );
dataTable->setNullText( "" );
dataTable->QTable::setColumnWidth( 3, 50 );
dataTable->QTable::setSorting(false);

dataTable->refresh(QDataTable::RefreshData);
dataTable->show();

/***************************************/

edm.

wysota
8th February 2007, 10:58
I am not making ORDER BY in Query SQL.

Exactly. That's why the database returns the data in an order other than you want. It probably sorts by primary key.

ederbs
9th February 2007, 00:47
It does not have to be this. I tried to pass "Query SQL" passing "ORDER BY" more the problem continues, the date and hour continues jumping for top when they are brought update.

http://200.193.29.195/qt3/AcompanhamentoForm.html

edm.