jiveaxe
25th January 2014, 10:27
Hi,
I'm porting my qt4 application to qt5. While it compiled successfully in qt 5.1 (if I'm not wrong), with version 5.2 I got the following compile error:
no match for ‘operator=’ (operand types are ‘QWeakPointer<MainWindow>’ and ‘MainWindow*’)
The error is triggered at this line:
m_mainWindow = new MainWindow();
where m_mainWindow is:
QWeakPointer<MainWindow> m_mainWindow;
and this is MainWindow:
mainwindow.h
//...
namespace Ui {
class MainWindow;
}
class MainWindow;
namespace The {
MainWindow* mainWindow();
}
class MainWindow : public QMainWindow
{
Q_OBJECT
friend MainWindow* The::mainWindow();
public:
explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
//...
};
mainwindow.cpp
QWeakPointer<MainWindow> MainWindow::s_instance;
namespace The {
MainWindow* mainWindow() { return MainWindow::s_instance.data(); }
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui_(new Ui::MainWindow)
{
//...
}
Anything changed in Qt 5.2 regarding QWeakPointer?
Regards
I'm porting my qt4 application to qt5. While it compiled successfully in qt 5.1 (if I'm not wrong), with version 5.2 I got the following compile error:
no match for ‘operator=’ (operand types are ‘QWeakPointer<MainWindow>’ and ‘MainWindow*’)
The error is triggered at this line:
m_mainWindow = new MainWindow();
where m_mainWindow is:
QWeakPointer<MainWindow> m_mainWindow;
and this is MainWindow:
mainwindow.h
//...
namespace Ui {
class MainWindow;
}
class MainWindow;
namespace The {
MainWindow* mainWindow();
}
class MainWindow : public QMainWindow
{
Q_OBJECT
friend MainWindow* The::mainWindow();
public:
explicit MainWindow(QWidget *parent = 0);
virtual ~MainWindow();
//...
};
mainwindow.cpp
QWeakPointer<MainWindow> MainWindow::s_instance;
namespace The {
MainWindow* mainWindow() { return MainWindow::s_instance.data(); }
}
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui_(new Ui::MainWindow)
{
//...
}
Anything changed in Qt 5.2 regarding QWeakPointer?
Regards