whell seems that the query is the problem, got the same problem with the loops:
for( int i=0; i<modelo->rowCount(); i++ )
{
for( int j=0; j<modelo->record().count(); j++ )
{
qDebug( qPrintable( modelo->record(i).value( j ).toString() ) );
}
qDebug( "--" );
}
for( int i=0; i<modelo->rowCount(); i++ )
{
for( int j=0; j<modelo->record().count(); j++ )
{
qDebug( qPrintable( modelo->record(i).value( j ).toString() ) );
}
qDebug( "--" );
}
To copy to clipboard, switch view to plain text mode
Debug: --
Debug: 99
Debug: Alimentos Balanceados
Debug: mijo
Debug: 3.000
Debug:
Debug:
Debug: --
Debug:
Debug:
Debug:
Debug:
Debug:
Debug:
Debug: --
Debug: --
Debug: 99
Debug: Alimentos Balanceados
Debug: mijo
Debug: 3.000
Debug:
Debug:
Debug: --
Debug:
Debug:
Debug:
Debug:
Debug:
Debug:
Debug: --
To copy to clipboard, switch view to plain text mode
The model is contructed like this
setTable( "producto" );
setHeaderData( 0, Qt::Horizontal, "#ID" );
setHeaderData( 1, Qt::Horizontal, "Categoria" );
setRelation
( 1,
QSqlRelation( "categoria",
"id",
"nombre" ) );
setHeaderData( 2, Qt::Horizontal, "Nombre" );
setHeaderData( 3, Qt::Horizontal, "Precio de Venta" );
setHeaderData( 4, Qt::Horizontal, "Descripcion" );
setHeaderData( 5, Qt::Horizontal, "Marca" );
setTable( "producto" );
setHeaderData( 0, Qt::Horizontal, "#ID" );
setHeaderData( 1, Qt::Horizontal, "Categoria" );
setRelation( 1, QSqlRelation( "categoria", "id", "nombre" ) );
setHeaderData( 2, Qt::Horizontal, "Nombre" );
setHeaderData( 3, Qt::Horizontal, "Precio de Venta" );
setHeaderData( 4, Qt::Horizontal, "Descripcion" );
setHeaderData( 5, Qt::Horizontal, "Marca" );
To copy to clipboard, switch view to plain text mode
and the table is
CREATE TABLE `producto` (
`id` bigint(1) NOT NULL auto_increment,
`id_categoria` int(1) NOT NULL,
`nombre` tinytext NOT NULL,
`precio_venta` decimal(6,3) NOT NULL,
`descripcion` text,
`marca` tinytext,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=256 DEFAULT CHARSET=latin1
CREATE TABLE `producto` (
`id` bigint(1) NOT NULL auto_increment,
`id_categoria` int(1) NOT NULL,
`nombre` tinytext NOT NULL,
`precio_venta` decimal(6,3) NOT NULL,
`descripcion` text,
`marca` tinytext,
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=256 DEFAULT CHARSET=latin1
To copy to clipboard, switch view to plain text mode
the modelo->query().executedQuery() returns
SELECT `producto`.`id`,`relTblAl_1`.`nombre` AS categoria_nombre,`producto`.`nombre`,`producto`.`precio_venta`,`producto`.`descripcion`,`producto`.`marca` FROM `producto`,`categoria` `relTblAl_1` WHERE (`producto`.`id_categoria`=`relTblAl_1`.`id`)
SELECT `producto`.`id`,`relTblAl_1`.`nombre` AS categoria_nombre,`producto`.`nombre`,`producto`.`precio_venta`,`producto`.`descripcion`,`producto`.`marca` FROM `producto`,`categoria` `relTblAl_1` WHERE (`producto`.`id_categoria`=`relTblAl_1`.`id`)
To copy to clipboard, switch view to plain text mode
The query works ok on mysql shell...
qt bug?
Any advice?
Bookmarks