Results 1 to 3 of 3

Thread: QMdiSubWindow - Warnings while compile

  1. #1
    Join Date
    Jan 2008
    Location
    Brasil
    Posts
    131
    Thanks
    18
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Exclamation QMdiSubWindow - Warnings while compile

    Hi,

    I'm getting messages from the compiler to compile warnings. I am developing an application in MDI and I have several that use the function createWidget to put the widget in MDIArea.

    Follow code example:

    MainWindow.cpp
    Qt Code:
    1. void MainWindow::showPed()
    2. {
    3. m_Ped = new Ped(this);
    4. createWidget(m_Ped);
    5. }
    6.  
    7. template<class T> T *MainWindow::createWidget(T *widget)
    8. {
    9. child = new QMdiSubWindow(this);
    10. child->setWidget(widget);
    11. child->setAttribute(Qt::WA_DeleteOnClose);
    12. mdiArea->addSubWindow(child);
    13.  
    14. QSize minSize = qobject_cast<T *>(widget)->minimumSize();
    15. QSize maxSize = qobject_cast<T *>(widget)->maximumSize();
    16.  
    17. if (minSize == maxSize)
    18. {
    19. child->setWindowFlags(child->windowFlags() & ~Qt::WindowMaximizeButtonHint);
    20. }
    21.  
    22. child->move(0,0);
    23. child->show();
    24. }
    To copy to clipboard, switch view to plain text mode 


    Output compiler (GNU/Linux - Fedora 10):
    MainWindow.cpp: In member function ‘T* MainWindow::createWidget(T*) [with T = Ped]’:
    MainWindow.cpp:721: warning: control reaches end of non-void function

    I wonder how I can resolve this, is the way I am doing is correct and I will not have future problems and suggestions for how to improve this code for reuse for other windows.

    Thanks,

    Marcelo E. Geyer

  2. #2
    Join Date
    Dec 2006
    Posts
    849
    Thanks
    6
    Thanked 163 Times in 151 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QMdiSubWindow - Warnings while compile

    You declare the function to return a T*, but you do not.
    Fix the warning by either "returning" void or by returning a T* as you claim to do.

  3. The following user says thank you to caduel for this useful post:

    estanisgeyer (3rd February 2009)

  4. #3
    Join Date
    Jan 2008
    Location
    Brasil
    Posts
    131
    Thanks
    18
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Smile Re: QMdiSubWindow - Warnings while compile

    You're right. As not seen it?
    Enjoying the discussion, that would be the most elegant way to reuse code in this situation? What would be the best way?

Similar Threads

  1. qtgui4.dll error in visual c++ 2005
    By Comptrol in forum Installation and Deployment
    Replies: 33
    Last Post: 19th June 2008, 07:18
  2. Access to PostgreSQL DB on a linux server
    By rmagro in forum Qt Programming
    Replies: 28
    Last Post: 13th March 2008, 09:02

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.