#include <QtGui/QApplication>#include <QtGui>#include "mainwindow.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); int n = 3; MainWindow mainwindow; QWidget wgt; QHBoxLayout* phbxToolLayout = new QHBoxLayout; QVBoxLayout* pvbxLayout = new QVBoxLayout; QLabel* lblN = new QLabel("Vvedite razmernost' matrici"); QLineEdit* leN = new QLineEdit; QPushButton* pbN = new QPushButton("Enter"); QTableWidget tbl(n, n); QObject::connect(leN, SIGNAL(textChanged(QString)), &mainwindow, SLOT(setRange(QString))); phbxToolLayout->addWidget(lblN); phbxToolLayout->addWidget(leN); phbxToolLayout->addWidget(pbN); pvbxLayout->addLayout(phbxToolLayout); pvbxLayout->addWidget(&tbl); wgt.setLayout(pvbxLayout); wgt.show(); mainwindow.setCentralWidget(&wgt); mainwindow.show(); return a.exec();}
#ifndef MAINWINDOW_H#define MAINWINDOW_H#include <QMainWindow>#include <QObject>namespace Ui { class MainWindow;}class MainWindow : public QMainWindow{ Q_OBJECTpublic: explicit MainWindow(QWidget *parent = 0); ~MainWindow();private: Ui::MainWindow *ui;public slots: void setRange(QString);};#endif // MAINWINDOW_H
#include "mainwindow.h"#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this);}void MainWindow::setRange(QString strN){ tbl.setRowCount(strN);}MainWindow::~MainWindow(){ delete ui;}
tbl.setRowCount(strN);
void MainWindow::setRange(QString strN){ tbl.setRowCount(strN);}
C++ (Qt)#include <QTableWidget> class MainWindow : public QMainWindow{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; QTableWidget tbl(n, n); public slots: void setRange(QString);};
#include <QtGui/QApplication>#include <QtGui>#include "mainwindow.h"int main(int argc, char *argv[]){ QApplication a(argc, argv); MainWindow mainwindow; mainwindow.show(); return a.exec();}
#include <QtGui>#include "mainwindow.h"#include "ui_mainwindow.h"MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ int n = 3; QWidget wgt; QHBoxLayout* phbxToolLayout = new QHBoxLayout; QVBoxLayout* pvbxLayout = new QVBoxLayout; QLabel* lblN = new QLabel("Vvedite razmernost' matrici"); QLineEdit* leN = new QLineEdit; QPushButton* pbN = new QPushButton("Enter"); QTableWidget tbl(n, n); QObject::connect(leN, SIGNAL(textChanged(QString)), SLOT(setRange(QString))); phbxToolLayout->addWidget(lblN); phbxToolLayout->addWidget(leN); phbxToolLayout->addWidget(pbN); pvbxLayout->addLayout(phbxToolLayout); pvbxLayout->addWidget(&tbl); wgt.setLayout(pvbxLayout); wgt.show(); setCentralWidget(&wgt); ui->setupUi(this);}void MainWindow::setRange(QString strN){ //tbl.setRowCount(strN);}MainWindow::~MainWindow(){ delete ui;}
void MainWindow::setRange(QString strN){ //tbl.setRowCount(strN);}
C++ (Qt)#include <QTableWidget> class MainWindow : public QMainWindow{ Q_OBJECT public: explicit MainWindow(QWidget *parent = 0); ~MainWindow(); private: Ui::MainWindow *ui; QTableWidget tbl(3, 3); public slots: void setRange(QString);};
C++ (Qt)#include <QtGui>#include "mainwindow.h"#include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow){ ui->setupUi(this); QWidget wgt; QHBoxLayout* phbxToolLayout = new QHBoxLayout; QVBoxLayout* pvbxLayout = new QVBoxLayout; QLabel* lblN = new QLabel("Vvedite razmernost' matrici"); QLineEdit* leN = new QLineEdit; QPushButton* pbN = new QPushButton("Enter"); QObject::connect(leN, SIGNAL(textChanged(QString)), SLOT(setRange(QString))); phbxToolLayout->addWidget(lblN); phbxToolLayout->addWidget(leN); phbxToolLayout->addWidget(pbN); pvbxLayout->addLayout(phbxToolLayout); pvbxLayout->addWidget(&tbl); wgt.setLayout(pvbxLayout); wgt.show(); setCentralWidget(&wgt); } void MainWindow::setRange(QString strN){ tbl.setRowCount(strN);} MainWindow::~MainWindow(){ delete ui;}
QTableWidget tbl(3, 3);