About the dynamic library relocation warning and findChild return NULL

6 views
Skip to first unread message

lvbing lvbing

unread,
Sep 10, 2013, 10:56:26 PM9/10/13
to qt-c...@googlegroups.com, qt-in...@trolltech.com, devel...@qt-project.org
Qt version:4.5.3
Platform :5.10 Generic_142909-17 sun4v sparc SUNW,SPARC-Enterprise-T5120  solaris-cc-64

When compile the code,has the warning:
ld:警告:重定位警告:R_SPARC_COPY:文件libdll_widget.so:符号 MDrawWidget::staticMetaObject:重定位绑定到具有STV_PROTECTED可见性的符号

Below is my test code:
1、The dynamic library: dll_widget,has an UI class MDRawWidget,inherits QWidget。
The class define:
class DLL_WIDGET_EXPORT MDrawWidget : public QWidget
{
    Q_OBJECT
public:
    MDrawWidget(QWidget* parent = 0,Qt::WindowFlags f = 0);
    ~MDrawWidget();
private:
    void Init()
};

This UI is just create a simple UI,like an QTabWidget,QPushButton。

2、an executable process: Widget_test
This process include the  library "dll_widget"
In the header file:
MDrawWidget* m_pDrawWidget;
In the source file:
m_pDrawWidget = new MDrawWidget(this);
m_pDrawWidget->setObjectName("DrawApcWidget");
---------------------------------------------------------------------------------------------------------------------------------
Now,The program is:
If I use the findChild to get the MDrawWidget object,When compile the code,it will be warning like up! and when run it,findChild will return NULL! 
The code like below:
MDrawWidget* pDrawWidget = findChild<MDrawWidget*>("DrawApcWidget");
if( pDrawWidget )
{
    //TODO
}
If I use the member pointer,it's OK
if( m_pDrawWidget )
{
    //TODO
}

At last,it run  OK in win7.

Thanks
Reply all
Reply to author
Forward
0 new messages