qt - QTableView's cells are empty, but headers show up -


text after "itemprop =" text ">

I created a representative pretty copied from QT's spin box representative example and I'm trying to fill a QTableView . However, I am getting a strange problem where table headers are shown but cells are empty and can not be clicked

 QTableView and representatives of the problem with

address to representatives: DoubleSpinBoxDelegate :: DoubleSpinBoxDelegate (QObject * parent): QItemDelegate (parent) {} QWidget * DoubleSpinBoxDelegate: : createEditor (QWidget * parent, const QStyleOptionViewItem & amp; alternative,

  #include "double_spinbox_delegate.h" Const QModelIndex and index) const {QDoubleSpinBox * editor = new QDoubleSpinBox (guardian); Editor & gt; SetValue (0); // if (index.column () == 0) {// editor-> Set minimum (0); // editor-> Setmaxime (255); //} // else {// editor-> Set minimum (0); // editor-> Set (1); // Return Editor; } Zero DoubleSpinBoxDelegate :: setEditorData (QWidget * Editor, constant QModelIndex & Index) constants {double value = index.model () -> Data (index, QT :: EditRole) .toDouble (); QDoubleSpinBox * Double SpinBox = Fixed_cast & lt; QDoubleSpinBox * & gt; (Editor); DoubleSpinBox-> SetValue (value); } Void DoubleSpinBoxDelegate :: setModelData (QWidget * editor, QAbstractItemModel * model, constant QModelIndex & amp; index) const {QDoubleSpinBox * doubleSpinBox = static_cast & LT; QDoubleSpinBox * & gt; (Editor); DoubleSpinBox-> InterpretText (); Double value = double spin box- & gt; Values ​​(); Model- & gt; Setdata (index, value, qt :: editor); } Void DoubleSpinBoxDelegate :: updateEditorGeometry (QWidget * editor, constant QStyleOptionViewItem & amp; alternative, constant QModelIndex & amp; index) const {Editor & gt; SetGeometry (option.rect); }   

And the function I'm calling in the form creator

  void MainWindow :: InitializeColorTable () {QTableView * tableColor = UI- & gt; TableColor; QStandardItemModel * Model = New QStandardItemModel (4, 4, ui- & gt; Table Collar); // QStandardItemModel * Model = this- & gt; Color Tables Module TableColor-> SetModel (model); DoubleSpinBox undisputed representative; TableColor-> SetItemDelegate (& amp; Representative); Model- & gt; Set Horizontal Header Labels (Qestring List) & lt; & Lt; Tr ("value") & lt; Tr ("R") & lt; & Lt; Tr ("G") & lt; & Lt; Tr ("B")); (Int Call = 0; call and Leftida; model & gt; column (); ++ Cola) {Kyuemdel index index = model (at row = 0; row & lt; model & gt; Panktikota (); ++ row) - & gt; Index (row, call, cumulode index ()); Model- & gt; SetData (index, quewrient (+ + + +0 +0) * (cola + 1.0)), QT :: editorial;}}}    

Your representative is allocated on the stack, and it has been removed after it exits from the scope. Double spinbox representative representative; TableColor-> setItemDelegate (& amp; Representative);

Instead, make your representative new.

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -