Qurl



  • How do I open multiple windows using QURL I currently have it set so when I click one button it opens a tab using the default browser. When I click the second button it opens another tab in the same Google chrome window. How do I make it so the second button opens the tab in a new chrome window. I don't want it to use the window that's already open.



  • @BridgerMiles
    QUrl (https://doc.qt.io/qt-5/qurl.html) in itself just handles URLs, it does not "open windows". Before we can answer whether you can achieve what you ask, tell us what code you have where you are using these QUrls and how you "open" them?



  • @JonB QDesktopServices::openUrl("www.google.com");
    QDesktopServices::openUrl("www.facebook.com");
    is Cody's executed Google opens in the first tab and Facebook opens in the second. I needed to open Google in one chrome window and Facebook and another chrome window.



  • @BridgerMiles
    I don't think you're going to be able to make openUrl() open a new window, rather than its default of a new tab.... I don't see it allows target=, and anyway I don't think that would help, it seems to be doing equivalent of target="_blank" already. It's really down to how your browser is set up, I think you'll find your Chrome browser is set to do new tabs rather than new windows, unless you change that there's nothing openUrl() can do to alter that behaviour.



  • @JonB ok thank you do you have any links or resources I can look into to find a way to make this work.


  • Lifetime Qt Champion

    Hi
    Alternatively, you could use QProcess and start it with

        QString program = "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe";
        QStringList arguments;
        arguments << "--new-window" << "https://forum.qt.io";
        QProcess chromeProcess;
        if ( ! chromeProcess.startDetached(program, arguments) ) {
            qDebug() << "error" << chromeProcess.errorString();
        }