Forum
Sign Up
× DataGrid for Qt.C++

multi row - column setting

9 years 9 months ago #1 by Kwangho Kim


I want to above column settings, but below screenshot was my result. ;-(



ps. qtitandatagrid documentation is hell!



void CManageUnapproveSWModel::createColumns()
{
if( m_view == NULLPTR )
return;

Qtitan::GridBandedTableView* spView = qobject_cast<Qtitan::GridBandedTableView*>(m_view);

auto spProcessBand = spView->addBand( tr( "??????" ) );
auto spBlockInfoBand = spView->addBand( tr( "????" ) );
auto spApproveInfoBand = spView->addBand( tr( "????" ) );

spProcessBand->setBandIndex( 0 );
spBlockInfoBand->setBandIndex( 1 );
spApproveInfoBand->setBandIndex( 2 );

((Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_SELECT ))->setEditorType( Qtitan::GridEditorType::CheckBoxEditorType );

setColumnProperty( TBL_AML_HDX_SELECT, 0, 0, 3 );

setColumnProperty( TBL_AML_HDX_ICON, 0, 0, 3 );

setColumnProperty( TBL_AML_HDX_FILENAME, 0, 0, 1 );
setColumnProperty( TBL_AML_HDX_APPROVESTAT, 0, 0, 1 );
setColumnProperty( TBL_AML_HDX_BLOCKCOUNT, 0, 0, 2 );

setColumnProperty( TBL_AML_HDX_COMPANYNAME, 1, 0, 1 );
setColumnProperty( TBL_AML_HDX_REQUESTDATE, 1, 0, 1 );

setColumnProperty( TBL_AML_HDX_PRODUCTNAME, 2, 0, 1 );
setColumnProperty( TBL_AML_HDX_RESPONSEDATE, 2, 0, 1 );
setColumnProperty( TBL_AML_HDX_LASTBLOCKDATE, 2, 0, 1 );

}


void CManageUnapproveSWModel::setColumnProperty( const QString& columnCaption, int rowIndex, int bandIndex, int rowSpan )
{
Qtitan::GridBandedTableColumn* colBase = NULLPTR;
Qtitan::GridBandedTableView* spView = qobject_cast<Qtitan::GridBandedTableView*>(m_view);

colBase = static_cast<Qtitan::GridBandedTableColumn*>(spView->getColumnByCaption( columnCaption ));
if( colBase == NULLPTR )
return;

if( rowIndex > 0 )
colBase->setRowIndex( rowIndex );
colBase->setBandIndex( bandIndex );
colBase->setRowSpan( rowSpan );

}
Attachments:

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #2 by Developer Machines
To configure that you need please exec the following code:
    view->beginUpdate();

    Qtitan::GridTableBand* selectBand = view->addBand("Band Select");  //Band index 0
    Qtitan::GridTableBand* iconBand = view->addBand("Band Icon"); //Band index 1
    Qtitan::GridTableBand* nameBand = view->addBand("Band Name"); //Band index 2
    Qtitan::GridTableBand* dateBand = view->addBand("Band Date"); //Band index 3
    Qtitan::GridTableBand* msicBand = view->addBand("Band Misc"); //Band index 4

    view->setModel(model, QModelIndex(), false);

    Qtitan::GridBandedTableColumn* column0 = (Qtitan::GridBandedTableColumn *)view->addColumn(0, "Select");
    column0->setBandIndex(selectBand->index() /* index is 0 */);
    column0->setRowSpan(3);

    Qtitan::GridBandedTableColumn* column1 = (Qtitan::GridBandedTableColumn *)view->addColumn(1, "Icon");
    column1->setBandIndex(iconBand->index() /* index is 1 */);
    column1->setRowSpan(3);

    Qtitan::GridBandedTableColumn* column2 = (Qtitan::GridBandedTableColumn *)view->addColumn(2, "FileName(Size)");
    column2->setBandIndex(nameBand->index() /* index is 2 */);
    column2->setRowIndex(0);

    Qtitan::GridBandedTableColumn* column3 = (Qtitan::GridBandedTableColumn *)view->addColumn(3, "CompanyName");
    column3->setBandIndex(nameBand->index() /* index is 2 */);
    column3->setRowIndex(1);

    Qtitan::GridBandedTableColumn* column4 = (Qtitan::GridBandedTableColumn *)view->addColumn(4, "ProductName");
    column4->setBandIndex(nameBand->index() /* index is 2 */);
    column4->setRowIndex(2);

    Qtitan::GridBandedTableColumn* column5 = (Qtitan::GridBandedTableColumn *)view->addColumn(5, "ApproveDate");
    column5->setBandIndex(dateBand->index() /* index is 3 */);
    column5->setRowIndex(0);

    Qtitan::GridBandedTableColumn* column6 = (Qtitan::GridBandedTableColumn *)view->addColumn(6, "RequestDate");
    column6->setBandIndex(dateBand->index() /* index is 3 */);
    column6->setRowIndex(1);

    Qtitan::GridBandedTableColumn* column7 = (Qtitan::GridBandedTableColumn *)view->addColumn(7, "ResponseDate");
    column7->setBandIndex(dateBand->index() /* index is 3 */);
    column7->setRowIndex(2);
        
    Qtitan::GridBandedTableColumn* column8 = (Qtitan::GridBandedTableColumn *)view->addColumn(8, "BlockCount");
    column8->setBandIndex(msicBand->index() /* index is 4 */);
    column8->setRowIndex(0);
    column8->setRowSpan(2);

    Qtitan::GridBandedTableColumn* column9 = (Qtitan::GridBandedTableColumn *)view->addColumn(9, "LastBlockDate");
    column9->setBandIndex(msicBand->index() /* index is 4 */);
    column9->setRowIndex(1);

    view->endUpdate();

Let me know the results.

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #3 by Kwangho Kim
ok thanks, abobe codes works well for me.
But, this code works only with setModel( autoCreateColumn = false )

If i use setMode( autoCreateColumn = true ), below screenshot was results.







void CManageUnapproveSWModel::createColumns()
{
if( m_view == NULLPTR )
return;

Qtitan::GridBandedTableView* spView = qobject_cast<Qtitan::GridBandedTableView*>(m_view);

spView->beginUpdate();

Qtitan::GridTableBand* selectBand = spView->addBand( "Band Select" ); //Band index 0
Qtitan::GridTableBand* iconBand = spView->addBand( "Band Icon" ); //Band index 1
Qtitan::GridTableBand* nameBand = spView->addBand( "Band Name" ); //Band index 2
Qtitan::GridTableBand* dateBand = spView->addBand( "Band Date" ); //Band index 3
Qtitan::GridTableBand* msicBand = spView->addBand( "Band Misc" ); //Band index 4

Qtitan::GridBandedTableColumn* column0 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_SELECT );
column0->setBandIndex( selectBand->index() /* index is 0 */ );
column0->setRowSpan( 3 );

Qtitan::GridBandedTableColumn* column1 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_ICON );
column1->setBandIndex( iconBand->index() /* index is 1 */ );
column1->setRowSpan( 3 );

Qtitan::GridBandedTableColumn* column2 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_FILENAME );
column2->setBandIndex( nameBand->index() /* index is 2 */ );
column2->setRowIndex( 0 );

Qtitan::GridBandedTableColumn* column3 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_COMPANYNAME );
column3->setBandIndex( nameBand->index() /* index is 2 */ );
column3->setRowIndex( 1 );

Qtitan::GridBandedTableColumn* column4 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_PRODUCTNAME );
column4->setBandIndex( nameBand->index() /* index is 2 */ );
column4->setRowIndex( 2 );

Qtitan::GridBandedTableColumn* column5 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_APPROVESTAT );
column5->setBandIndex( dateBand->index() /* index is 3 */ );
column5->setRowIndex( 0 );

Qtitan::GridBandedTableColumn* column6 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_REQUESTDATE );
column6->setBandIndex( dateBand->index() /* index is 3 */ );
column6->setRowIndex( 1 );

Qtitan::GridBandedTableColumn* column7 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_RESPONSEDATE );
column7->setBandIndex( dateBand->index() /* index is 3 */ );
column7->setRowIndex( 2 );

Qtitan::GridBandedTableColumn* column8 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_BLOCKCOUNT );
column8->setBandIndex( msicBand->index() /* index is 4 */ );
column8->setRowIndex( 0 );
column8->setRowSpan( 2 );

Qtitan::GridBandedTableColumn* column9 = (Qtitan::GridBandedTableColumn *)spView->getColumnByCaption( TBL_AML_HDX_LASTBLOCKDATE );
column9->setBandIndex( msicBand->index() /* index is 4 */ );
column9->setRowIndex( 1 );

spView->endUpdate();
}


QVariant CManageUnapproveSWModel::headerData( int section, Qt::Orientation orientation, int role /*= Qt::DisplayRole */ ) const
{
QVariant vtHeaderData;

do
{
if( orientation != Qt::Horizontal )
break;

if( role != Qt::DisplayRole )
break;

switch( section )
{
// ?? ??? ?? ?? ??
case 0:
vtHeaderData = TBL_AML_HDX_SELECT;
break;
case 1:
vtHeaderData = TBL_AML_HDX_ICON;
break;
case 2:
vtHeaderData = TBL_AML_HDX_FILENAME;
break;
case 3:
vtHeaderData = TBL_AML_HDX_COMPANYNAME;
break;
case 4:
vtHeaderData = TBL_AML_HDX_PRODUCTNAME;
break;
case 5:
vtHeaderData = TBL_AML_HDX_APPROVESTAT;
break;
case 6:
vtHeaderData = TBL_AML_HDX_REQUESTDATE;
break;
case 7:
vtHeaderData = TBL_AML_HDX_RESPONSEDATE;
break;
case 8:
vtHeaderData = TBL_AML_HDX_BLOCKCOUNT;
break;
case 9:
vtHeaderData = TBL_AML_HDX_LASTBLOCKDATE;
break;

}

} while (false);

return vtHeaderData;
}


CManageUnapproveSWUI::CManageUnapproveSWUI( QWidget* parent /*= 0 */ )
: QDialog( parent, Qt::FramelessWindowHint )
{
ui.setupUi( this );

// std::wstring xmlFile = nsCommon::nsCmnFormatter::tsFormat( L"%1\\%2", nsCommon::nsCmnPath::GetCurrentPath(), SVC_CONFIG_NAME );
//
// if( PathFileExistsW( xmlFile.c_str() ) != FALSE )
// _customSQLModel.init( CU2U8(xmlFile).c_str(), "//tblAmalgamationItem/column", "TBL_AMALGAMATION_LOG" );
// else
// {
// xmlFile = nsCommon::nsCmnFormatter::tsFormat( L"%1\\%2.sample", nsCommon::nsCmnPath::GetCurrentPath(), SVC_CONFIG_NAME );
// if( PathFileExistsW( xmlFile.c_str() ) != FALSE )
// _customSQLModel.init( CU2U8( xmlFile ).c_str(), "//tblAmalgamationItem/column", "TBL_AMALGAMATION_LOG" );
// }

ui.tblUnapproveSW->setViewType( Qtitan::Grid::BandedTableView );
auto tblAmalgamation = ui.tblUnapproveSW->view< Qtitan::GridBandedTableView >();
auto& tblOptions = tblAmalgamation->options();

tblOptions.setGroupsHeader( false );
tblOptions.setBandsHeader( false );
tblOptions.setColumnAutoWidth( true );
tblOptions.setRowAutoHeight( true );

_amalgamationItemModel.init( tblAmalgamation );
tblAmalgamation->setModel( &_amalgamationItemModel, QModelIndex(), true );
_amalgamationItemModel.createColumns();
}
Attachments:

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago - 9 years 9 months ago #4 by Developer Machines
In case of autoCreateColumn = true grid creates one band by default for adding created columns to it (i.e. selectBand->index() is 1 ). Please do tblOptions.setBandsHeader( true ); to see what happens. So you have to remove this first unused band after createColumns() for instance or get first band and rename it to "Band Select".
Last edit: 9 years 9 months ago by Developer Machines.

Please Log in or Create an account to join the conversation.

More
9 years 9 months ago #5 by Kwangho Kim
Oh, Thanks for your reply.

Please Log in or Create an account to join the conversation.

More
  • Not Allowed: to create new topic.
  • Not Allowed: to reply.
  • Not Allowed: to edit your message.
Moderators: Developer Machines
Time to create page: 0.240 seconds

Developer Newsletter

Join our Developer Machines newsletter to get informed on all the latest releases of the commercial components for Qt.C++, Delphi FireMonkey, updates and general knowledges.

Quick Support

Should you need any additional information about our products or licensing, please contact us at the following email addresses:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

  • This email address is being protected from spambots. You need JavaScript enabled to view it.

Get in Touch

If you would like to purchase our products or services, but don’t know how to do it the right way, please feel free to contact us:

  • This email address is being protected from spambots. You need JavaScript enabled to view it.( any questions related to our products or services )
  • This email address is being protected from spambots. You need JavaScript enabled to view it.( questions related to licensing )