diro
29th November 2010, 05:34
Hi all,
I design a custom widget(named MyPanel) inheritanced QWidget, and I add a QListWidget inside it. The QListWidget works well, but if I try to replace the text with a custom widget via setItemWidget(), it looks well, but the scrolling is failed (The custom widgets won't scroll..)
If I create the MyPanel object, it works:
MyPanel panel;
panel.show() // The custom widget and scrollbar works well.
But if I create the MyPanel inside another QWidget, it fails:
class BigPanel:QDialog
{
...
MyPanel *panel = new MyPanel(this);
QVBoxLayout* layout_v = new QVBoxLayout(this);
setLayout(layout_v);
layout_v->addWidget(panel, 0, Qt::AlignCenter);
...
}
Does anybody have idea on it? Thanks~
Added after 1 45 minutes:
According to my test, I found that if I add the BigPanel into the QGraphicsScene by QGraphicsScene::addWidget(), it will fail. So I guess it may due to the event propagation issue.
I design a custom widget(named MyPanel) inheritanced QWidget, and I add a QListWidget inside it. The QListWidget works well, but if I try to replace the text with a custom widget via setItemWidget(), it looks well, but the scrolling is failed (The custom widgets won't scroll..)
If I create the MyPanel object, it works:
MyPanel panel;
panel.show() // The custom widget and scrollbar works well.
But if I create the MyPanel inside another QWidget, it fails:
class BigPanel:QDialog
{
...
MyPanel *panel = new MyPanel(this);
QVBoxLayout* layout_v = new QVBoxLayout(this);
setLayout(layout_v);
layout_v->addWidget(panel, 0, Qt::AlignCenter);
...
}
Does anybody have idea on it? Thanks~
Added after 1 45 minutes:
According to my test, I found that if I add the BigPanel into the QGraphicsScene by QGraphicsScene::addWidget(), it will fail. So I guess it may due to the event propagation issue.