Advertisement
Guest User

qt qtablewidget qlineedit issue qdoublevalidator

a guest
Mar 22nd, 2013
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.54 KB | None | 0 0
  1. #include <QWidget>
  2. #include <QTableWidget>
  3. #include <QHBoxLayout>
  4. #include <QDomDocument>
  5. #include <QFile>
  6. #include <QFileDialog>
  7. #include <QDoubleValidator>
  8. #include <QLineEdit>
  9.  
  10. #include "PrintArea.h"
  11.  
  12. class MainWidget : public QWidget
  13. {
  14.   Q_OBJECT
  15. public:
  16.   explicit MainWidget(QWidget *parent = 0);
  17.  
  18. public slots:
  19.   int saveFile();
  20.   void newFile();
  21.   int openFile();
  22.   void myCellChanged(int i, int j);
  23.  
  24.  
  25. signals:
  26. //  void documentChange(QTableWidgetItem * item);
  27.  
  28. private:
  29.   QDomElement RowToNode( QDomDocument&, const QTableWidget*, const int);
  30.   bool xmlWrite(const QString& p);
  31.   int xmlRead(const QString& p);
  32.  
  33.   QFileDialog* dialog;
  34.   QHBoxLayout *horizontalLayout;
  35.   QTableWidget *sheet;
  36.   PrintArea *printArea;//distruggere!
  37.   QDoubleValidator *validator;
  38.   QLineEdit *lineEdit;
  39.  
  40.   QFile currentFile;
  41.   bool modified;
  42. };
  43.  
  44. //CPP file:
  45. class Exc{};
  46.  
  47. MainWidget::MainWidget(QWidget *parent) : QWidget(parent), modified(false) {
  48.   sheet = new QTableWidget(30,3, this);//settare righe e colonne dyn!!!!!!!!!!!!!!!!!!!!!
  49.   horizontalLayout = new QHBoxLayout;
  50.   printArea = new PrintArea(this);
  51.   horizontalLayout->addWidget(sheet);
  52.   horizontalLayout->addWidget(printArea);
  53.   setLayout(horizontalLayout);
  54.   connect(sheet, SIGNAL(cellChanged ( int, int)), this, SLOT(myCellChanged(int, int)));
  55.  
  56.   validator = new QDoubleValidator(this);
  57. }
  58.  
  59.  
  60. void MainWidget::myCellChanged(int i, int j)
  61. {
  62.   lineEdit = new QLineEdit(sheet);
  63.   lineEdit->setValidator(validator);
  64.   sheet->setCellWidget(i,j,lineEdit);
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement