Guest User

Untitled

a guest
May 25th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #include "MainWindow.h"
  2. #include "ui_MainWindow.h"
  3. #include <QGraphicsScene>
  4. #include <QGraphicsProxyWidget>
  5. #include <QGraphicsView>
  6. #include <QTableWidget>
  7.  
  8. MainWindow::MainWindow( QWidget *parent ) :
  9. QMainWindow( parent ),
  10. ui( new Ui::MainWindow )
  11. {
  12. ui->setupUi( this );
  13.  
  14. QGraphicsView *view = new QGraphicsView ;
  15. QGraphicsScene *scene = new QGraphicsScene ;
  16. scene->setSceneRect( 0, 0, 1000, 1000 );
  17. QGraphicsProxyWidget *item = new QGraphicsProxyWidget ;
  18. QTableWidget *table = new QTableWidget ;
  19. table->setRowCount( 10 );
  20. table->setColumnCount( 5 );
  21. table->setHorizontalHeaderLabels( QStringList() << "1" << "2" << "3" << "4" << "5" );
  22. table->setGeometry( 0, 0, 640, 480 );
  23. item->setWidget( table );
  24. scene->addItem( item );
  25. scene->setFocusItem( item );
  26. view->setScene( scene );
  27. setCentralWidget( view );
  28. }
  29.  
  30. MainWindow::~MainWindow()
  31. {
  32. delete ui;
  33. }
  34.  
  35. #ifndef MAINWINDOW_H
  36. #define MAINWINDOW_H
  37.  
  38. #include <QMainWindow>
  39.  
  40. namespace Ui {
  41. class MainWindow;
  42. }
  43.  
  44. class MainWindow : public QMainWindow
  45. {
  46. Q_OBJECT
  47.  
  48. public:
  49. explicit MainWindow(QWidget *parent = 0);
  50. ~MainWindow();
  51.  
  52. private:
  53. Ui::MainWindow *ui;
  54. };
  55.  
  56. #endif // MAINWINDOW_H
Add Comment
Please, Sign In to add comment