Hi,
As I told you, you can use a QList of QTableWidget pointers like this:
[LIST=1][*][COLOR=#0000ff]void[/COLOR] MainWindow[COLOR=#000000]::[/COLOR][COLOR=#009900]createFilesTable[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]int[/COLOR] TagCount,[URL="http://doc.qt.nokia.com/latest/qstring.html"]QString[/URL] FileName[COLOR=#000000])[/COLOR]
[*][COLOR=#000000]{[/COLOR]
[*]
[*] filesTable [COLOR=#000000]=[/COLOR] [COLOR=#009900]new[/COLOR] [URL="http://doc.qt.nokia.com/latest/qtablewidget.html"]QTableWidget[/URL][COLOR=#000000]([/COLOR][COLOR=#0000dd]0[/COLOR],TagCount[COLOR=#000000])[/COLOR];
[*] filesTable[COLOR=#000000]-[/COLOR]>setSelectionBehavior[COLOR=#000000]([/COLOR][URL="http://doc.qt.nokia.com/latest/qabstractitemview.html"]QAbstractItemView[/URL][COLOR=#000000]::[/COLOR][COLOR=#009900]SelectRows[/COLOR][COLOR=#000000])[/COLOR];
[*] filesTable[COLOR=#000000]-[/COLOR]>horizontalHeader[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]-[/COLOR]>setResizeMode[COLOR=#000000]([/COLOR][COLOR=#0000dd]0[/COLOR], [URL="http://doc.qt.nokia.com/latest/qheaderview.html"]QHeaderView[/URL][COLOR=#000000]::[/COLOR][COLOR=#009900]Stretch[/COLOR][COLOR=#000000])[/COLOR];
[*] filesTable[COLOR=#000000]-[/COLOR]>verticalHeader[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]-[/COLOR]>hide[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[*] ui[COLOR=#000000]-[/COLOR]>tabWidget[COLOR=#000000]-[/COLOR]>addTab[COLOR=#000000]([/COLOR]filesTable,FileName[COLOR=#000000])[/COLOR];
[*] tableList.append(filesTable); //Add the QTableWidget to the list
[*][COLOR=#000000]}[/COLOR]
[/LIST]
[LIST=1][*][COLOR=#0000ff]void[/COLOR] MainWindow[COLOR=#000000]::[/COLOR][COLOR=#009900]createFilesTable[/COLOR][COLOR=#000000]([/COLOR][COLOR=#0000ff]int[/COLOR] TagCount,[URL="http://doc.qt.nokia.com/latest/qstring.html"]QString[/URL] FileName[COLOR=#000000])[/COLOR]
[*][COLOR=#000000]{[/COLOR]
[*]
[*] filesTable [COLOR=#000000]=[/COLOR] [COLOR=#009900]new[/COLOR] [URL="http://doc.qt.nokia.com/latest/qtablewidget.html"]QTableWidget[/URL][COLOR=#000000]([/COLOR][COLOR=#0000dd]0[/COLOR],TagCount[COLOR=#000000])[/COLOR];
[*] filesTable[COLOR=#000000]-[/COLOR]>setSelectionBehavior[COLOR=#000000]([/COLOR][URL="http://doc.qt.nokia.com/latest/qabstractitemview.html"]QAbstractItemView[/URL][COLOR=#000000]::[/COLOR][COLOR=#009900]SelectRows[/COLOR][COLOR=#000000])[/COLOR];
[*] filesTable[COLOR=#000000]-[/COLOR]>horizontalHeader[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]-[/COLOR]>setResizeMode[COLOR=#000000]([/COLOR][COLOR=#0000dd]0[/COLOR], [URL="http://doc.qt.nokia.com/latest/qheaderview.html"]QHeaderView[/URL][COLOR=#000000]::[/COLOR][COLOR=#009900]Stretch[/COLOR][COLOR=#000000])[/COLOR];
[*] filesTable[COLOR=#000000]-[/COLOR]>verticalHeader[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR][COLOR=#000000]-[/COLOR]>hide[COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR];
[*] ui[COLOR=#000000]-[/COLOR]>tabWidget[COLOR=#000000]-[/COLOR]>addTab[COLOR=#000000]([/COLOR]filesTable,FileName[COLOR=#000000])[/COLOR];
[*] tableList.append(filesTable); //Add the QTableWidget to the list
[*][COLOR=#000000]}[/COLOR]
[/LIST]
To copy to clipboard, switch view to plain text mode
Then you can, as Spitfire told you, connect currentChanged( index ) signal to a slot and use index variable to obtain the QTableWidget pointer from the list:
void MainWindow::tabIndexChanged(int index)
{
...
}
void MainWindow::tabIndexChanged(int index)
{
QTableWidget* tableWidget = tableList.at(index);
...
}
To copy to clipboard, switch view to plain text mode
Of course that you can use your method, but what happens if there is more than one widget into the tab? You have to search on the child widgets if there is one QTableWidget. but there will be another problem if there is more that one QTableWidget childs into the tab.
Bookmarks