Results 1 to 6 of 6

Thread: Not-So-Fancy Browser doesn't open windows

  1. #1
    Join Date
    Oct 2013
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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?

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: Not-So-Fancy Browser doesn't open windows


  3. #3
    Join Date
    Oct 2013
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not-So-Fancy Browser doesn't open windows

    Quote Originally Posted by ChrisW67 View Post

    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:

    Qt Code:
    1. MainWindow::MainWindow(const QUrl& url)
    2. {
    3.  
    4. QNetworkProxyFactory::setUseSystemConfiguration(true);
    5.  
    6. view = new QWebView(this);
    7.  
    8. view->settings()->setAttribute(QWebSettings::PluginsEnabled, true);
    9. view->settings()->setAttribute(QWebSettings::JavascriptCanOpenWindows, true);
    10. view->settings()->setAttribute(QWebSettings::JavascriptCanCloseWindows, true);
    11. view->settings()->setAttribute(QWebSettings::JavascriptCanAccessClipboard, true);
    12. view->settings()->setAttribute(QWebSettings::LocalStorageEnabled, true);
    13. view->settings()->enablePersistentStorage(QString("/data"));
    14.  
    15. view->setContextMenuPolicy(Qt::NoContextMenu);
    16.  
    17. showFullScreen();
    18.  
    19. view->load(url);
    20.  
    21. setCentralWidget(view);
    22.  
    23. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Oct 2013
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default 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.

  5. #5
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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,
    _

  6. #6
    Join Date
    Oct 2013
    Posts
    4
    Qt products
    Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Not-So-Fancy Browser doesn't open windows

    Quote Originally Posted by anda_skoa View Post
    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!

Similar Threads

  1. Fancy Browser and Virtual keyboard support
    By Vigneshkumar in forum Qt Programming
    Replies: 1
    Last Post: 7th May 2013, 22:49
  2. Fancy Browser and Virtual keyboard support
    By Veerapandian in forum Qt Programming
    Replies: 0
    Last Post: 7th May 2013, 06:27
  3. Fancy Browser, Windows Server 2008 and empty webpage
    By drewpt in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2011, 00:35
  4. Replies: 0
    Last Post: 17th March 2011, 03:17
  5. Not able to run fancy browser and demo browser example applications
    By GoGetIt in forum Installation and Deployment
    Replies: 1
    Last Post: 16th August 2010, 06:23

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.