示例#1
0
/** void QTableView::setModel(DataSource *model)
 * bind/QTableView.h:12
 */
static int TableView_setModel(lua_State *L) {
  try {
    TableView *self = *((TableView **)dub_checksdata(L, 1, "mimas.TableView"));
    DataSource *model = *((DataSource **)dub_checksdata(L, 2, "mimas.DataSource"));
    self->setModel(model);
    return 0;
  } catch (std::exception &e) {
    lua_pushfstring(L, "setModel: %s", e.what());
  } catch (...) {
    lua_pushfstring(L, "setModel: Unknown exception");
  }
  return dub_error(L);
}
示例#2
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;
}
示例#3
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);
}
示例#4
0
文件: sample.cpp 项目: IMAN4K/QtPro
int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QStandardItemModel model;

for ( int col = 0; col < 3; col++ )
{
    QList<QStandardItem*> list;
    for ( int row = 0; row < 5; row++ )
    {
        list.append(new QStandardItem);
    }
    model.appendColumn(list);
}

TableView view;

view.setModel(&model);
view.show();

return a.exec&#40;&#41;;
}