Results 1 to 3 of 3

Thread: QMdiArea / SubWindow Problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    42
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default QMdiArea / SubWindow Problem

    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"
    Qt Code:
    1. TextEditorWidget::TextEditorWidget(QWidget *parent,const QString &file)
    2. : QFrame(parent)
    3. {
    4. setFrameStyle(QFrame::StyledPanel|QFrame::Sunken);
    5. setMidLineWidth(2);
    6.  
    7. editor = new QTextEdit(this);
    8. editor->setAcceptRichText(true);
    9. ...
    10. lineNumbers = new LineNumbers(this);
    11.  
    12. QHBoxLayout *editorLayout = new QHBoxLayout;
    13. editorLayout->setSpacing(0);
    14. editorLayout->addWidget(lineNumbers);
    15. editorLayout->addWidget(editor);
    16. editorLayout->setContentsMargins(0,0,0,0);
    17.  
    18. this->setLayout(editorLayout);
    19. ...
    To copy to clipboard, switch view to plain text mode 

    "My add to MDIarea method"
    Qt Code:
    1. void MainWindow::createEditor()
    2. {
    3. QMdiSubWindow *child = new QMdiSubWindow(componentArea);
    4. TextEditorWidget *editor = new TextEditorWidget(child);
    5.  
    6. child->setWidget(editor);
    7. child->setAttribute(Qt::WA_DeleteOnClose);
    8.  
    9. componentArea->addSubWindow(child);
    10. child->show();
    11. }
    To copy to clipboard, switch view to plain text mode 

    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
    Attached Images Attached Images

Similar Threads

  1. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  2. Grid Layout Problem
    By Seema Rao in forum Qt Programming
    Replies: 2
    Last Post: 4th May 2006, 12:45
  3. Problem with bitBlt
    By yellowmat in forum Newbie
    Replies: 1
    Last Post: 5th April 2006, 14:08
  4. fftw problem
    By lordy in forum General Programming
    Replies: 1
    Last Post: 16th March 2006, 21:36
  5. Replies: 16
    Last Post: 7th March 2006, 15:57

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.