Exemple #1
0
void CarShopMenu::gameStateLoaded(Client::State* state)
{
	model.reset(new VehicleTableModel(state->getShopVehicles()));

	TableView* view = ui->carList;

	view->setModel(model.get());
	connect(ui->carList->selectionModel(), SIGNAL(currentChanged(QModelIndex, QModelIndex)), this, SLOT(onCurrentChanged(QModelIndex, QModelIndex)));

	view->showColumn(model->name.getIndex());
	view->showColumn(model->price.getIndex());

	view->horizontalHeader()->setResizeMode(model->name.getIndex(), QHeaderView::Stretch);

	player = state->getPlayer();
	vehicle = nullptr;
}
Exemple #2
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QSpreadsheetHeaderView *headView = new QSpreadsheetHeaderView(Qt::Horizontal, this);
    headView->setSectionsClickable(true);
    headView->setHighlightSections(true);
    TableModel *model = new TableModel(this);
    TableView *tableView = new TableView(this);

    tableView->setModel(model);
    tableView->setHorizontalHeader(headView);
    tableView->horizontalHeader()->setStretchLastSection(true);

    setCentralWidget(tableView);
}