예제 #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;;
}