ericV
18th September 2009, 13:09
Hi,
I am currently working on an MDIbased Project.
I ahve set up an MDI area, and am working on adding different widgets to it.
But i am having problems with one of my Widgets. It is a custom codeeditor widget subclassed from QFrame, that contains a QTextEdit and a QWidget in which i draw the linenumbers.
"My Editor Constructor"
TextEditorWidget::TextEditorWidget(QWidget *parent,const QString &file)
: QFrame(parent)
{
setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);
setMidLineWidth(2);
editor = new QTextEdit(this);
editor->setAcceptRichText(true);
...
lineNumbers = new LineNumbers(this);
QHBoxLayout *editorLayout = new QHBoxLayout;
editorLayout->setSpacing(0);
editorLayout->addWidget(lineNumbers);
editorLayout->addWidget(editor);
editorLayout->setContentsMargins(0,0,0,0);
this->setLayout(editorLayout);
...
"My add to MDIarea method"
void MainWindow::createEditor()
{
QMdiSubWindow *child = new QMdiSubWindow(componentArea);
TextEditorWidget *editor = new TextEditorWidget(child);
child->setWidget(editor);
child->setAttribute(Qt::WA_DeleteOnClose);
componentArea->addSubWindow(child);
child->show();
}
I have done prety much the same with other widgets, but with this one i get the following problems/errors:
when the method is called the following apears on the console:
"QMdiArea::addSubWindow: window is already added"
and The window itself does not get painted properly at first, only after i move it it gets drawn properly. I have attached a screenshot with a before-and-after.
I just can't figure out why it's giving me problems with this widget, it works fine for a QListwidget subclass and other QFrame sublcasses.
Maybe someone has already encountered this problem and can point me in the right directions.
Thanks for reading.
Eric
I am currently working on an MDIbased Project.
I ahve set up an MDI area, and am working on adding different widgets to it.
But i am having problems with one of my Widgets. It is a custom codeeditor widget subclassed from QFrame, that contains a QTextEdit and a QWidget in which i draw the linenumbers.
"My Editor Constructor"
TextEditorWidget::TextEditorWidget(QWidget *parent,const QString &file)
: QFrame(parent)
{
setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);
setMidLineWidth(2);
editor = new QTextEdit(this);
editor->setAcceptRichText(true);
...
lineNumbers = new LineNumbers(this);
QHBoxLayout *editorLayout = new QHBoxLayout;
editorLayout->setSpacing(0);
editorLayout->addWidget(lineNumbers);
editorLayout->addWidget(editor);
editorLayout->setContentsMargins(0,0,0,0);
this->setLayout(editorLayout);
...
"My add to MDIarea method"
void MainWindow::createEditor()
{
QMdiSubWindow *child = new QMdiSubWindow(componentArea);
TextEditorWidget *editor = new TextEditorWidget(child);
child->setWidget(editor);
child->setAttribute(Qt::WA_DeleteOnClose);
componentArea->addSubWindow(child);
child->show();
}
I have done prety much the same with other widgets, but with this one i get the following problems/errors:
when the method is called the following apears on the console:
"QMdiArea::addSubWindow: window is already added"
and The window itself does not get painted properly at first, only after i move it it gets drawn properly. I have attached a screenshot with a before-and-after.
I just can't figure out why it's giving me problems with this widget, it works fine for a QListwidget subclass and other QFrame sublcasses.
Maybe someone has already encountered this problem and can point me in the right directions.
Thanks for reading.
Eric