PDA

View Full Version : QMdiSubWindow - Warnings while compile



estanisgeyer
3rd February 2009, 14:11
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


void MainWindow::showPed()
{
m_Ped = new Ped(this);
createWidget(m_Ped);
}

template<class T> T *MainWindow::createWidget(T *widget)
{
child = new QMdiSubWindow(this);
child->setWidget(widget);
child->setAttribute(Qt::WA_DeleteOnClose);
mdiArea->addSubWindow(child);

QSize minSize = qobject_cast<T *>(widget)->minimumSize();
QSize maxSize = qobject_cast<T *>(widget)->maximumSize();

if (minSize == maxSize)
{
child->setWindowFlags(child->windowFlags() & ~Qt::WindowMaximizeButtonHint);
}

child->move(0,0);
child->show();
}



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

caduel
3rd February 2009, 14:30
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.

estanisgeyer
3rd February 2009, 15:37
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?