[Qt-interest] Change layout in subclass of standard widget ?
Stephen Collyer
scollyer at netspinner.co.uk
Mon May 25 22:05:11 CEST 2009
I'm trying to derive from a QTableView, to create a custom widget
comprising the table view, and a couple of QPushButtons, like so:
class MDPTableView : public QTableView
{
Q_OBJECT
public:
MDPTableView(QWidget* parent = 0);
..
private:
QPushButton* delete_;
QPushButton* edit_;
};
In the ctor, I try to lay out the widgets like so:
MDPTableView::MDPTableView(QWidget* parent)
: QTableView(parent)
{
delete_ = new QPushButton(tr("Delete"), this);
edit_ = new QPushButton(tr("Edit"), this);
QHBoxLayout* button_layout = new QHBoxLayout;
button_layout->addWidget(delete_);
button_layout->addWidget(edit_);
QVBoxLayout* main_layout = new QVBoxLayout;
main_layout->addWidget(this);
main_layout->addLayout(button_layout);
setLayout(main_layout);
}
However, this doesn't work: the app's main window is never shown, and
the problem seems to be my attempt to add "this" to main_layout.
How does one go about changing the layout of a derived standard
widget in this case ? I'm doing something wrong, but can't see how
to fix it.
--
Stephen Collyer
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090525/f6a5e42d/attachment.html
More information about the Qt-interest-old
mailing list