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();
}
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();
}
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
Bookmarks