Hmm... Sorry, it seems I was unclear. I just got it working using a derived class. I've attached a picture which should answer those questions, and copied in the header file which has solved the problem.
I derived from QTableWidget, hooked up the constructors as required, defined a couple new slots, promoted the tables to my derived version, added the custom slot with the edit button in the designer, and was able to hook up the spin boxes as needed.
2014-04-14 17_27_34-Matrix Multiplier.jpg
Header file:
#ifndef MATRIXWIDGET_H
#define MATRIXWIDGET_H
#include <QTableWidget>
{
Q_OBJECT
public:
explicit MatrixWidget
(QWidget *parent
= 0) { ;}
MatrixWidget
(int rows,
int columns,
QWidget *parent
= 0) { ;}
private slots:
void setNumRows(int n)
{
this->setRowCount(n);
}
void setNumColumns(int n)
{
this->setColumnCount(n);
}
};
#endif // MATRIXWIDGET_H
#ifndef MATRIXWIDGET_H
#define MATRIXWIDGET_H
#include <QTableWidget>
class MatrixWidget : public QTableWidget
{
Q_OBJECT
public:
explicit MatrixWidget(QWidget *parent = 0)
: QTableWidget(parent)
{ ;}
MatrixWidget(int rows, int columns, QWidget *parent = 0)
: QTableWidget(rows, columns, parent)
{ ;}
private slots:
void setNumRows(int n)
{
this->setRowCount(n);
}
void setNumColumns(int n)
{
this->setColumnCount(n);
}
};
#endif // MATRIXWIDGET_H
To copy to clipboard, switch view to plain text mode
Bookmarks