Not-So-Fancy Browser doesn't open windows
Hi,
i'm new to both c++ and Qt and started using it because I need a kind of Kioskbrowser which shall only access one web application (I programmed), in full screen mode. So I took the "Fancy Browser" from the examples and got rid of everything I didn't need. I found how to switch it in full screen mode and how to adjust some settings like enabling (Flash- & PDF viewer-)PlugIns, LocalStorage and other stuff I need. It is almost in a state I want it but than I came across a problem I haven't been able to solve:
The web application uses Javascript open() and close() methods for new windows. But my not-so-fancy browser just doesn't react and stays in its one window. After some googling I decided to ask here as there are a lot of concepts I haven't got a clue about involved, and maybe there's an easy answer. How to make it open and close new full screen windows via Javascript? And close the application should there be only one window open?
Re: Not-So-Fancy Browser doesn't open windows
Re: Not-So-Fancy Browser doesn't open windows
Quote:
Originally Posted by
ChrisW67
Well, thanks I guess but that doesn't really help me. I found references to this already and have the setting "JavascriptCanOpenWindows" in my little bunch of tweaks. But I have no idea where and how (and why) to reimplement createWindows. I tried to add stuff like this in plenty variations but I don't know where to put it and how to make it work with what I already have. Here's my MainWindow - what's left from FancyBrowser and settings added by me:
Code:
MainWindow::MainWindow(const QUrl& url)
{
QNetworkProxyFactory::setUseSystemConfiguration(true);
view = new QWebView(this);
view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
view->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
view->settings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true);
view->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
view->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
view
->settings
()->enablePersistentStorage
(QString("/data"));
view->setContextMenuPolicy(Qt::NoContextMenu);
showFullScreen();
view->load(url);
setCentralWidget(view);
}
Re: Not-So-Fancy Browser doesn't open windows
Hi, it's me again.
After switching to Python it was a bit easier for me to make myself familiar with the qtwebkit stuff and I managed to solve the problem described in the OP. The last hurdle to "my own browser" is to get persistent cookies to work. I managed to tap the cookies when they arrive in my own cookiejar via setCookiesFromUrl and write them into a file. As "my browser" will only visit my own page I don't have to care about anything but name and value of the cookies.
I figured that putting them back on the way to the website works via cookiesForUrl, but now I have the problem that I don't know what to do with the data I got back from my file. How to return them from the function? I have a simple string "key1=value1;key2=value2;..." in my file. No matter if I try to return it as string or array, it doesn't arrive. Does it have to have a special name, or is "return" not the way at all? Or am I at the wrong place with cookiesForUrl? Any help appreciated.
Re: Not-So-Fancy Browser doesn't open windows
Well, the C++ API returns a list of QNeworkCookie objects.
Have you tried to create and Python array of these?
Cheers,
_
Re: Not-So-Fancy Browser doesn't open windows
Quote:
Originally Posted by
anda_skoa
Well, the C++ API returns a list of QNeworkCookie objects.
Have you tried to create and Python array of these?
Cheers,
_
I thought in that direction and did try to create a QNetworkCookie object, but wasn't sure if on the right track and didn't went any further with experiments in that direction. Thanks to your post I followed up on it and had my cookies working in short time. :)
Besten Dank nach Graz!