On 2008-11-14 10:21:26 +0100, 李瑞 <[EMAIL PROTECTED]> said:

> 
> 
> Hi,
> 
>    I found a curious problem when I embed an Cocoa WebView into the QDialog.
> 
>    The sample code is that
> 
> #include <QtGui/QtGui>
> #include <Cocoa/Cocoa.h>
> #include <WebKit/WebKit.h>
> #include <QMacCocoaViewContainer>
> 
> int main(int argc, char **argv)
> {
>     QApplication app(argc, argv);
> 
>     QDialog qDialog;
> 
>     NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
> 
>     NSRect rect = {{0, 0},{qDialog.frameSize().width(), 
> qDialog.frameSize().height()}};
>     WebView *webView = [[WebView alloc] initWithFrame:rect 
> frameName:nil groupName:nil];
> QMacCocoaViewContainer macCocoaViewContainer(webView, &qDialog);
> 
>     QHBoxLayout hBoxlayout;
>     hBoxlayout.addWidget(&macCocoaViewContainer);
> qDialog.setLayout(&hBoxlayout);
> 
>     [[static_cast<WebView *> (macCocoaViewContainer.cocoaView()) 
> mainFrame] loadRequest:[NSURLRequest requestWithURL:[NSURL 
> URLWithString:[NSString stringWithString:@"http://www.google.com";]]]];
>     qDialog.resize(800,600);
> macCocoaViewContainer.show();
> 
> qDialog.show();//This works rightly, and it could show the 
> http://www.google.com web page.
>                //But when it is changed to qDialog.exec(), the web page 
> could not be showed. Why?
> 
>     [pool release];
> 
>     return app.exec();
> }
> 
> This code could work rightly and it will show the "www.google.com" web 
> page embedded in the dialog. However when I change the   qDialog.show() 
>    to   qDialog.exec(),  the web page could not showed.
> 
> The qDialog.exec() is our required,  please check this sample code.

Hello,

The code doesn't seem to have anything to do with Qt, but instead has 
something to do with WebView. It seems that WebView doesn't want to 
load a page if it is inside a modal dialog. If I replace the Qt code 
with straight Cocoa code, I get the same result. You may have to check 
on some Cocoa sites to understand why as this is a bit outside the 
scope of Qt.

If you need to display webpages inside of a modal dialog, you might be 
able to do this QWebFrame.

Hope this helps,

-- Trenton

_______________________________________________
Qt4-preview-feedback mailing list
[email protected]
http://lists.trolltech.com/mailman/listinfo/qt4-preview-feedback

Reply via email to