[Qt-interest] Change layout in subclass of standard widget ?
Malyushytsky, Alex
alex at wai.com
Sat May 30 03:14:46 CEST 2009
I think I am lost in the whole discussion, but if talk about original problem, it is easily solved
by having your widget not derived from QTableView, but from QWidget and have a QTableView as a child widget.
You can add any widgets you want with this approach.
Regards,
Alex
From: qt-interest-bounces at trolltech.com [mailto:qt-interest-bounces at trolltech.com] On Behalf Of Stephen Collyer
Sent: Monday, May 25, 2009 1:05 PM
To: qtInterest
Subject: [Qt-interest] Change layout in subclass of standard widget ?
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
---------------------------------------------------------------------------------------------------
Weidlinger Associates, Inc. made the following annotations.
“This message and any attachments are solely for the intended recipient and may contain confidential or privileged information. If you are not the intended recipient, any disclosure, copying, use, or distribution of the information included in this message and any attachments is prohibited. If you have received this communication in error, please notify us by reply e-mail and immediately and permanently delete this message and any attachments. Thank you.”
“Please consider our environment before printing this email.”
More information about the Qt-interest-old
mailing list