Version:

O3DE UI Table View Component

Use the table view component to present multiple columns of structured data in a table format. By default, this component employs sortable columns and “zebra striping” - where the background color of rows alternate - to help you create an easily readable, scannable, and sortable presentation of data.

component table view example

Note:
AzQtComponents::TableView actually derives from QTreeView, not QTableView, to provide more customization over the size of rows.

Basic table view

component table view basic

Create a simple logging table view.

Note:
If a table view is combined with a tree view, you might need to turn off zebra striping in one of the widgets using the setAlternatingRowColors(false) function.

Example

#include <AzQtComponents/Components/Widgets/TableView.h>
#include <AzToolsFramework/UI/Logging/LogTableModel.h>
#include <AzToolsFramework/UI/Logging/LogLine.h>
#include <QDateTime>

// Create a log table model for this example.
auto logModel = new AzToolsFramework::Logging::LogTableModel(this);

// Create the table view.
auto tableView = new AzQtComponents::TableView(parent);

// Set the model for the table.
tableView->setModel(logModel);

// Add a few lines of sample data.
logModel->AppendLine(
    AzToolsFramework::Logging::LogLine(
        "An informative message for debugging purposes.",
        "Window",
        AzToolsFramework::Logging::LogLine::TYPE_MESSAGE,
        QDateTime::currentMSecsSinceEpoch()));

logModel->AppendLine(
    AzToolsFramework::Logging::LogLine(
        "A warning message for things that may not have gone as expected.",
        "Window",
        AzToolsFramework::Logging::LogLine::TYPE_WARNING,
        QDateTime::currentMSecsSinceEpoch()));

logModel->AppendLine(
    AzToolsFramework::Logging::LogLine(
        "Critical error message, something went wrong.",
        "Window",
        AzToolsFramework::Logging::LogLine::TYPE_ERROR,
        QDateTime::currentMSecsSinceEpoch()));

C++ API reference

For details on the table view API, see the following topic in the O3DE UI Extensions C++ API Reference:

Relevant Qt documentation includes the following topics: