Ok, I get it now.
That's actually very easy:
MainWindow
::MainWindow(QWidget *parent
) :
{
this->table->setRowCount( 100 );
this->table->setColumnCount( 10 );
this->setCentralWidget( this->table );
QToolBar* tb
= this
->addToolBar
( "Test" );
tb->addAction( "Test", this, SLOT( test() ) );
}
void MainWindow::test( void )
{
qDebug() << this->table->rowAt( 0 ) << "-" << this->table->rowAt( this->table->height() ); // this is what you want
qDebug() << this->table->columnAt( 0 ) << "-" << this->table->columnAt( this->table->width() ); // this is what you want
}
MainWindow::MainWindow(QWidget *parent)
:
QMainWindow(parent),
table( new QTableWidget() )
{
this->table->setRowCount( 100 );
this->table->setColumnCount( 10 );
this->setCentralWidget( this->table );
QToolBar* tb = this->addToolBar( "Test" );
tb->addAction( "Test", this, SLOT( test() ) );
}
void MainWindow::test( void )
{
qDebug() << this->table->rowAt( 0 ) << "-" << this->table->rowAt( this->table->height() ); // this is what you want
qDebug() << this->table->columnAt( 0 ) << "-" << this->table->columnAt( this->table->width() ); // this is what you want
}
To copy to clipboard, switch view to plain text mode
Edit:
You can also use indexAt( table->rect.topLeft() ) and indexAt( table->rect().bottomRight() ) if index is more convenient for you.
Bookmarks