Results 1 to 2 of 2

Thread: Resizing Mfc dialog with embeded QWinWidget

  1. #1
    Join Date
    Jul 2009
    Posts
    40
    Thanks
    7

    Default Resizing Mfc dialog with embeded QWinWidget

    Hello

    I have an Mfc dialog with QWinWidget inside it.
    When I resize my dialog I want my QWinWidget to automatically
    be resized and repositioned as well. This is the code that creates the QWinWidget inside the mfc dialog :

    Qt Code:
    1. int MyCDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
    2. {
    3. if (CDialog::OnCreate( lpCreateStruct ) == -1 )
    4. return -1;
    5. win=new QWinWidget( this->m_hWnd );
    6. MyFrame * dialog=new MyFrame(win);
    7. win->move(0,0);
    8. win->show();
    9. return 0;
    10. }
    To copy to clipboard, switch view to plain text mode 

    MyFrame is derived from QFrame object. The QFrame object is made
    with Qt designer. QFrame has assigned layout, which suppose to do geometrical managment of QFrame child widgets.

    Here is the code that executes when I drag the resizing border of my dialog :
    Qt Code:
    1. void MyCDailog::OnSize()
    2. {
    3. QObjectList list=win->children();
    4. QFrame* p=(QFrame*) list.at(0);
    5. p->resize(QSize(cx,cy));
    6. }
    To copy to clipboard, switch view to plain text mode 

    When the dialog is resized I am calling the resize method of my frame
    object, and I was expecting that after I do resize to the frame
    ,the frame should resize and repositon its child widgets according to
    their size hint and size polices. But this is not happening, at least
    not as it should. What I am doing wrong ?
    Thanks

  2. #2
    Join Date
    Jul 2009
    Posts
    40
    Thanks
    7

    Default Re: Resizing Mfc dialog with embeded QWinWidget

    Now I added layout to my QWinWidget and it seems to work .Although I am not sure why.

    Qt Code:
    1. int MyCDialog::OnCreate(LPCREATESTRUCT lpCreateStruct)
    2. {
    3. if (CDialog::OnCreate( lpCreateStruct ) == -1 )
    4. return -1;
    5. win=new QWinWidget( this->m_hWnd );
    6. MyFrame * dialog=new MyFrame(win);
    7. QVBoxLayout mylayout=new QVBoxLayout ;
    8. mylayout->addWidget(dialog);
    9. win->setLayout(mylayout);
    10. win->move(0,0);
    11. win->show();
    12. return 0;
    13. }
    To copy to clipboard, switch view to plain text mode 

    and in my OnSize handler :

    Qt Code:
    1. void MyCDailog::OnSize(UINT nType,int cx,int cy)
    2. {
    3. win->resize(cx,cy);
    4.  
    5. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  2. disabling resizing of a dialog
    By deepakn in forum Newbie
    Replies: 2
    Last Post: 21st June 2007, 09:14
  3. Resizing the dialog box dynamically
    By vvbkumar in forum Newbie
    Replies: 5
    Last Post: 20th June 2006, 08:54
  4. Show/hide part of dialog with resizing.
    By Spockmeat in forum Qt Tools
    Replies: 6
    Last Post: 7th June 2006, 08:22
  5. Problem with resizing dialog
    By Seema Rao in forum Qt Programming
    Replies: 8
    Last Post: 5th May 2006, 17:27

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.