Results 1 to 10 of 10

Thread: Make an example of QT in MDI

  1. #1
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Red face Make an example of QT in MDI

    in the examples of QT is one is called "Paint and Plug", wanted to pass it to MDI, then I made a class of QScrollArea type but don't show me that I specify to him in setWidget, then I do not know in which it mistakes to me or How I can pass it to MDI?

  2. #2
    Join Date
    May 2006
    Posts
    28
    Thanks
    8
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Make an example of QT in MDI

    It'd be helpfull if you could post some code to let us understand better what your trying to do.

    here's the code from: http://doc.trolltech.com/4.1/qscrollarea.html

    Qt Code:
    1. QLabel *imageLabel = new QLabel;
    2. QImage image("happyguy.png");
    3. imageLabel->setPixmap(QPixmap::fromImage(image));
    4.  
    5. scrollArea = new QScrollArea;
    6. scrollArea->setBackgroundRole(QPalette::Dark);
    7. scrollArea->setWidget(imageLabel);
    To copy to clipboard, switch view to plain text mode 

    Presumably you can add a widget to the mdi. Perhaps you need to pass some p ointers between widgets and the MDI.

  3. #3
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Make an example of QT in MDI

    well i make a two class
    Qt Code:
    1. class Win: public QScrollArea
    2. {
    3. ...
    4. }
    5. class paintArea: public QWidget
    6. {
    7. ...
    8. private:
    9. void paintEvent(QEvent *event);
    10. QImage Paper;
    11. ...
    12. }
    To copy to clipboard, switch view to plain text mode 
    in the constructor of win class:
    Qt Code:
    1. Win::Win(QWidget *parent): QScrollArea(parent)
    2. {
    3. paintArea *paper = new paintArea;
    4. setBackgroundRole(QPalette::Dark);
    5. setWidget(paper);
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    in the constructor of paintarea class i define a QImage name's Paper. in the function apintEvent of paintarea draw the image Paper.

    When i create a mdichild with win class show a window with Dark Background, but never show the paint area,What is my mistake?

  4. #4
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Make an example of QT in MDI

    When i create a mdichild with win class show a window with Dark Background, but never show the paint area,
    What you're saying doesn't make sense! If you see a window with dark background then it is what you call a paint area...
    Current Qt projects : QCodeEdit, RotiDeCode

  5. #5
    Join Date
    May 2006
    Posts
    28
    Thanks
    8
    Thanked 3 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default

    in the MDI example from : qt4 docs

    Qt Code:
    1. MdiChild *child = createMdiChild();
    2. child->newFile();
    3. child->show();
    To copy to clipboard, switch view to plain text mode 

    I am a QT beginner, but how I use the documentation examples is to copy code and delete all the code that I dont need. This makes me understand what code is needed to make something work.

    I dont think you use PaintEvent to draw the image. Sorry I cant help more...

  6. #6
    Join Date
    Jan 2006
    Location
    travelling
    Posts
    1,116
    Thanks
    8
    Thanked 127 Times in 121 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Make an example of QT in MDI

    Quote Originally Posted by avis_phoenix
    in the constructor of win class:
    Qt Code:
    1. Win::Win(QWidget *parent): QScrollArea(parent)
    2. {
    3. paintArea *paper = new paintArea;
    4. setBackgroundRole(QPalette::Dark);
    5. setWidget(paper);
    6. ...
    7. }
    To copy to clipboard, switch view to plain text mode 
    What is my mistake?
    1) Using setWidget() is wrong... your paint area becomes the only child of the scrollarea so there can't be any MDI...
    2) If nothing appear except a background there can be two reasons : paintArea is not explicitely shown or its paintEvent() is not working properly...
    3) If MDI is what you trully want then why are you using QScrollArea and not QWorkspace???
    4) Hope this helps...
    Current Qt projects : QCodeEdit, RotiDeCode

  7. #7
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Make an example of QT in MDI

    But the mdi child is win class not a paintarea, in another class use a QWorkspace for make mdi this window and mdichild a win class.

  8. #8
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Make an example of QT in MDI

    well i found mi error, was a stupid error, only change that:
    Qt Code:
    1. Win::Win(QWidget *parent): QScrollArea(parent)
    2. {
    3. paintArea *paper = new paintArea;
    4. setBackgroundRole(QPalette::Dark);
    5. setWidget(paper);
    6. paper->show();
    7. ...
    8. }
    To copy to clipboard, switch view to plain text mode 

    that's all
    Last edited by avis_phoenix; 19th June 2006 at 17:12. Reason: Don't show a bold font in code

  9. #9
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: Make an example of QT in MDI

    Hmm, there's most likely something wrong with your widgets' parent-child relationships (QScrollArea should reparent the "paint area" widget correctly during setWidget(), though). You shouldn't have to explicitly call show() in a situation like yours. Which exact version of Qt is this?
    Last edited by jpn; 19th June 2006 at 19:42. Reason: Rephrased
    J-P Nurmi

  10. #10
    Join Date
    May 2006
    Posts
    57
    Thanks
    12
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Make an example of QT in MDI

    Well, but without show() don't show the widget in QScrollArea, my version of QT is 4.1.2

Similar Threads

  1. Qt-4.1 and FC4 with make
    By probine in forum Installation and Deployment
    Replies: 3
    Last Post: 24th December 2007, 21:10
  2. Qt/Embedded Installation error during make
    By mahe2310 in forum Installation and Deployment
    Replies: 5
    Last Post: 7th September 2006, 04:05
  3. make install with debug_and_release_target
    By aba in forum Qt Programming
    Replies: 0
    Last Post: 17th April 2006, 19:28
  4. How to make QTimeEdit Box readable only
    By Krishnacins in forum Qt Programming
    Replies: 3
    Last Post: 6th March 2006, 08:10
  5. Error with make
    By probine in forum Installation and Deployment
    Replies: 1
    Last Post: 13th February 2006, 13:07

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.