Hello!
I am trying to force a subclass I made called Spreadsheet to automatically expand to the borders of its parent widget.
Here is appearing as it is, and the red arrows show what I am trying to achieve :
I did not post all the code, only the code that I thought was relevant.
spreadsheet.hpp
#ifndef SPREADSHEET_HPP
#define SPREADSHEET_HPP
#include <QTableWidget>
{
Q_OBJECT
public:
Spreadsheet
(int r,
int c,
QWidget *parent
= 0);
private:
};
#endif
#ifndef SPREADSHEET_HPP
#define SPREADSHEET_HPP
#include <QTableWidget>
class Spreadsheet : public QTableWidget
{
Q_OBJECT
public:
Spreadsheet(int r, int c, QWidget *parent = 0);
private:
QTableWidget* table;
};
#endif
To copy to clipboard, switch view to plain text mode
spreadsheet.cc
#include <QtGui>
#include "spreadsheet.hpp"
{
}
#include <QtGui>
#include "spreadsheet.hpp"
Spreadsheet::Spreadsheet(int r, int c, QWidget* parent) : QTableWidget(parent)
{
table = new QTableWidget(r,c,this);
}
To copy to clipboard, switch view to plain text mode
mainwindow.cc constructor
MainWindow::MainWindow()
{
setCentralWidget(widget);
sp = new Spreadsheet(200,5, tabWidget); // sp is of type Spreadsheet
tabWidget->addTab(sp, tr("First Tab"));
layout->setMargin(3);
layout->addWidget(tabWidget);
widget->setLayout(layout);
createActions();
createMenus();
QString message
= tr
("Begin by opening a previous file ");
statusBar()->showMessage(message);
setWindowTitle(tr("Menus"));
}
MainWindow::MainWindow()
{
QWidget* widget = new QWidget;
setCentralWidget(widget);
tabWidget = new QTabWidget;
sp = new Spreadsheet(200,5, tabWidget); // sp is of type Spreadsheet
tabWidget->addTab(sp, tr("First Tab"));
QHBoxLayout* layout = new QHBoxLayout;
layout->setMargin(3);
layout->addWidget(tabWidget);
widget->setLayout(layout);
createActions();
createMenus();
QString message = tr("Begin by opening a previous file ");
statusBar()->showMessage(message);
setWindowTitle(tr("Menus"));
}
To copy to clipboard, switch view to plain text mode
How would I go about achieving of what is demonstrated with the arrows?
Thanks
Bookmarks