views::views(QWidget *parent): QDialog(parent){ cbx = new QComboBox(); Vlayout = new QVBoxLayout; Hlayout = new QHBoxLayout; view = new QTableView(); editmodel = new editablemodel(this); editAct = new QAction( tr("Edit"), view); showMoreAct = new QAction( tr("Show more"), view); showCell = new QAction( tr("Show edited cell"), view); view->setModel(model); view->setItemDelegate(new QSqlRelationalDelegate(view));//------------кнопки------------------- Hlayout->addWidget(btnUndo); Hlayout->addWidget(btnUndoAll); Hlayout->addWidget(btnExit); Vlayout->addLayout(Hlayout); Vlayout->addWidget(view); e=0; connect( editAct, SIGNAL(triggered()), this, SLOT(edit())); connect( showMoreAct,SIGNAL(triggered()), this, SLOT(show_more())); connect( showCell, SIGNAL(triggered()), this, SLOT(select_row())); //connect( btnPlay, SIGNAL(clicked()), this, SLOT(cell_play())); connect( btnUndo, SIGNAL(clicked()), this, SLOT(undo())); connect( btnUndoAll, SIGNAL(clicked()), this, SLOT(undo_all())); connect( btnExit, SIGNAL(clicked()), this, SLOT(edit_end())); connect(view, SIGNAL(cellChanged(int, int)), this, SLOT(select_row(int,int))); setLayout(Vlayout); resize(1200,400); setWindowTitle(tr("Tables")); }//------откат на шаг-------void views::undo(){ }//------отменить все---------void views::undo_all(){ }//---------начать редактирование----------void views::edit(){ editmodel = new editablemodel(this); view->setModel(editmodel); }//---------выделение отредактированной строки------void views::select_row(){ view->selectRow(editmodel->row.toInt()-1); //edit();}void views::select_row(int row, int column){ row=row+1; column=column+1; view->selectRow(row); }//--------завершить редактирование------void views::edit_end(){ }//----------отобразить полную информацию по ячейке------------void views::show_more(){ }void views::contextMenuEvent(QContextMenuEvent *event){ QMenu menu(view); menu.addAction(editAct); menu.addAction(showMoreAct); menu.addAction(showCell); view->addAction(editAct); view->addAction(showMoreAct); view->addAction(showCell); menu.exec(event->globalPos());}views::~views(){}
class views : public QDialog{ Q_OBJECTpublic: views(QWidget *parent=0); ~views(); QVariant a,r; tablemodel *model; editablemodel *editmodel; strings *str; int e,c; void step(int &c); QTableView *view,*viewedit,*viewMore; //void select_row(); private: Ui::viewsClass ui; queries *edits; QSqlQueryModel *model_more,*model_1; QAction *editAct,*showMoreAct,*showCell; QVBoxLayout *Vlayout; QHBoxLayout *Hlayout; QPushButton *btnUndo,*btnUndoAll,*btnExit; QComboBox *cbx; QSqlQuery *query5;protected: void contextMenuEvent(QContextMenuEvent *event);//signals:// void cellChanged(int, int); public slots: void undo(); void undo_all(); void edit_end(); void select_row(); void select_row(int row, int column); void edit(); void show_more();};#endif // VIEWS_H
void views::select_row(int row, int column){ QMessageBox::information(this, "Application name","Unable to find the user preferences file.\n""The factory default will be used instead.");}
SIGNAL(currentChanged(const QModelIndex &, const QModelIndex &))...void views::select_row(const QModelIndex &, const QModelIndex &){ .... }
voidselect_row(const QModelIndex &, const QModelIndex &);