Promethee
18th January 2006, 11:19
Hi everybody,
I would like to make a view of my own, containing some widgets layouted in a QGridLayout. So I sub classed QAbstractItemView. But I have a problem with the function setContentsMargins() : this function does nothing. What is strange is that with a QFrame (parent of QAbstractItemView), it is possible to set the margins. Here is my code:
QTextEdit* textEdit1 = new QTextEdit;
QTextEdit* textEdit2 = new QTextEdit;
MyOwnView* myView = new MyOwnView(this);
myView->setContentsMargins(50,50,50,50);
QGridLayout* gridLayout1 = new QGridLayout(myView);
gridLayout1->addWidget(textEdit1, 0, 0);
myView->setLayout(gridLayout1);
QFrame* frame = new QFrame(this);
frame->setContentsMargins(50,50,50,50);
QGridLayout* gridLayout2 = new QGridLayout(frame);
gridLayout2->addWidget(textEdit2, 0, 0);
frame->setLayout(gridLayout2);
QStackedWidget* stackedWidget = new QStackedWidget(this);
stackedWidget->addWidget(myView);
stackedWidget->addWidget(frame);
setCentralWidget(stackedWidget);
On the first attached image the QTextEdit is inside a QFrame and the second one it is inside a QAbstractItemView
Did somebody experiment the same issue? Is it a Qt bug or one of my own?
I would like to make a view of my own, containing some widgets layouted in a QGridLayout. So I sub classed QAbstractItemView. But I have a problem with the function setContentsMargins() : this function does nothing. What is strange is that with a QFrame (parent of QAbstractItemView), it is possible to set the margins. Here is my code:
QTextEdit* textEdit1 = new QTextEdit;
QTextEdit* textEdit2 = new QTextEdit;
MyOwnView* myView = new MyOwnView(this);
myView->setContentsMargins(50,50,50,50);
QGridLayout* gridLayout1 = new QGridLayout(myView);
gridLayout1->addWidget(textEdit1, 0, 0);
myView->setLayout(gridLayout1);
QFrame* frame = new QFrame(this);
frame->setContentsMargins(50,50,50,50);
QGridLayout* gridLayout2 = new QGridLayout(frame);
gridLayout2->addWidget(textEdit2, 0, 0);
frame->setLayout(gridLayout2);
QStackedWidget* stackedWidget = new QStackedWidget(this);
stackedWidget->addWidget(myView);
stackedWidget->addWidget(frame);
setCentralWidget(stackedWidget);
On the first attached image the QTextEdit is inside a QFrame and the second one it is inside a QAbstractItemView
Did somebody experiment the same issue? Is it a Qt bug or one of my own?