I am trying to put a VboxLayout inside a QScrollArea. I have this to work with the code below with QPushButton, but if I try a custom widget I maed with QtDesigner the widget is not displayed.
One thing I tried was just to create a VBoxlayout (without a scroll area) and add my custom widget to it, and this worked fine. So it must have something to do with the scroll area setup, but I cannot tell.
Here is my code. (qpb1 shows up fine, but ne1 does not show up) (ui.frame is a QScrollArea)
NameEntry
* ne1
= new NameEntry
("John",
"NU",
QPixmap(":/fb/images/1604859.jpg"),
"123456789", p
);
layout->addWidget(ne1);
layout->addWidget(qpb1);
qw->setLayout(layout);
ui.frame->setWidget(qw);
QPushButton * qpb1 = new QPushButton("Jack");
NameEntry * ne1 = new NameEntry("John", "NU", QPixmap(":/fb/images/1604859.jpg"), "123456789", p );
QWidget * qw = new QWidget();
QVBoxLayout * layout = new QVBoxLayout();
layout->addWidget(ne1);
layout->addWidget(qpb1);
qw->setLayout(layout);
ui.frame->setWidget(qw);
To copy to clipboard, switch view to plain text mode
Thanks for the help.
Here is a snip from NameEntry if that is needed:
Q_OBJECT
public:
ui.setupUi(this);
setName(name);
setInfo(info);
setImage(image);
}
class NameEntry : public QWidget {
Q_OBJECT
public:
NameEntry(QString name, QString info, QPixmap image, QString id, Profile & p, QWidget *parent = 0) :
QWidget(parent), p(p), idNum(id) {
ui.setupUi(this);
setName(name);
setInfo(info);
setImage(image);
}
To copy to clipboard, switch view to plain text mode
Bookmarks