This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center
                            
                        
                    
                
                                6年前关闭。
            
                    
我正在使用qt4并将Webkit视图嵌入其中。 webkit对象期望QUrl对象包含URL。我的代码如下所示:

QUrl *application = new QUrl();

if (argc < 2) {
  application->setUrl(DEFAULT_PAGE);
}
else {
  application->setUrl(argv[2]);
}
view->load(application);
view->show();


但是view->load(application);在这里失败了,因为view->load需要一个(const QUrl&),而我正在传递(QUrl*&)

我像这样取消引用了应用程序对象:

view->load(&application);


但这将application转换为(QUrl**)

如何将application转换为(const QUrl&)

最佳答案

像这样:

view->load(*application);


请参见dereference operator

关于c++ - C++中简单的解除引用指针问题,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/14307716/

10-13 05:32