qt

Ответить
ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

qt

Сообщение ya »

qt creator
https://download.qt.io/official_releases/qtcreator/13.0/13.0.2/

Модули https://download.qt.io/official_releases/qt/5.15/5.15.14/submodules/
устанавливать через QT creator -> о модулях -> установить модуль

win





https://www.msys2.org/
https://www.msys2.org/docs/package-management/
Команда для установки Qt Creator, Qt 5.15.10, Qt 6 (latest available), а также некоторых других зависимостей msys2

Код: Выделить всё

pacman -S base base-devel mingw-w64-x86_64-toolchain mingw-w64-x86_64-qt-creator mingw-w64-x86_64-qt6-static mingw-w64-x86_64-cmake mingw-w64-x86_64-clang mingw-w64-x86_64-cc mingw-w64-x86_64-clang mingw-w64-x86_64-qt5-static  mingw-w64-x86_64-vulkan-headers mingw-w64-x86_64-python mingw-w64-x86_64-clang-tools-extra 

Код: Выделить всё

pacman -S mingw-w64-x86_64-cmake-gui

Код: Выделить всё

 pacman -S mingw-w64-x86_64-kicad-meta
msys2

Код: Выделить всё

pacman -Syu             // Обновление пакетов
pacman -S mingw-w64-x86_64-qt5   // Установка Qt5
pacman -S mingw-w64-x86_64-qt5-webengine  // Установка QWebEngineView
 pacman -S mingw-w64-x86_64-qt5-webview
Список доступных пакетов:
https://packages.msys2.org/groups/mingw-w64-x86_64-qt5
для их установки в msys2 использовать:

Код: Выделить всё

pacman -S mingw-w64-x86_64-qt5

Код: Выделить всё

pacman -S mingw-w64-x86_64-qt5-debug

Код: Выделить всё

pacman -S mingw-w64-x86_64-kf5

Код: Выделить всё

pacman -S mingw-w64-x86_64-ccmake mingw-w64-x86_64-cmakerc

Код: Выделить всё

pacman -S mingw-w64-x86_64-qtwebkit

Код: Выделить всё

pacman -S mingw-w64-x86_64-libevent
https://www.qt.io/offline-installers
https://download.qt.io/official_releases/qt/6.7/6.7.2/submodules/
https://www.qt.io/download-qt-installer
https://mirrors.20i.com/pub/qt.io/archive/qt-installer-framework/4.8.0/QtInstallerFramework-windows-x64-4.8.0.exe

Build Tools для Visual Studio 2019:
https://visualstudio.microsoft.com/ru/downloads/ в разделе "Инструменты для Visual Studio 2019"

Windows 10 SDK:
https://developer.microsoft.com/en-us/windows/downloads/windows-sdk/

CMake:
https://cmake.org/download/

Qt:
https://www.qt.io/offline-installers

Библиотеки:
https://code.qt.io/cgit/qt/

Linux qtcreator

Код: Выделить всё

sudo apt install qtcreator libkf5webkit-dev qtwebengine5-dev
test: Запуск внешней программы:
cpp/web3/web3/main.cpp

Код: Выделить всё

/*
#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}
*/


#include <QApplication>
#include <QProcess>
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget window;
    window.setWindowTitle("Запуск другой программы");
    window.resize(400, 300);

    QVBoxLayout *layout = new QVBoxLayout(&window);

    QPushButton *button1 = new QPushButton("cloud", &window);
    layout->addWidget(button1);

    QPushButton *button2 = new QPushButton("doc", &window);
    layout->addWidget(button2);


    QProcess process;
    QObject::connect(button1, &QPushButton::clicked, [&process]() {
        process.start("/usr/bin/google-chrome-stable cloud.phoenix-ekb.ru");
    });

    QObject::connect(button2, &QPushButton::clicked, [&process]() {
        process.start("/usr/bin/google-chrome-stable doc.phoenix-ekb.ru");
    });


    window.show();

    return app.exec();
}
gt@deb:~$ 
ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

Re: qt

Сообщение ya »

test: Кастомный веб-браузер

web4/main.cpp

Код: Выделить всё

/*
#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    MainWindow w;
    w.show();
    return a.exec();
}
*/


#include <QApplication>
#include <QProcess>
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include <QWebView>
#include <QString>
#include <QWebPage>
//#include <KWebView>

/*
class QWebPageChrome : public QWebPage
{
Q_OBJECT
public:
QString userAgentForUrl ( const QUrl & url ) const;
};

class QWebPageFirefox : public QWebPage
{
Q_OBJECT
public:
QString userAgentForUrl ( const QUrl & url ) const;
};

QString QWebPageChrome::userAgentForUrl ( const QUrl &url ) const
{
return "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2";
}
QString QWebPageFirefox::userAgentForUrl ( const QUrl &url ) const
{
return "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20100101 Firefox/8.0";
}
*/

class UserAgentWebPage : public QWebPage {
    QString userAgentForUrl(const QUrl &url ) const {
        return QString("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2");
    }
};

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget window;
    window.setWindowTitle("Запуск другой программы");
    window.resize(1600, 900);

    QVBoxLayout *layout = new QVBoxLayout(&window);

    QWebView *webView = new QWebView();
    layout->addWidget(webView);
    //webView->setRawHeader("User-Agent", "your customized user-agent");

    //load(request);



    //QWebView *chromeView = new QWebView(this);
    //QWebView *firefoxView = new QWebView(this);
    //QWebPageChrome *pageChrome= new QWebPageChrome();
   // QWebPageFirefox *pageFirefox= new QWebPageFirefox();
    //webView->setPage(pageChrome);
   // webView->setPage(pageFirefox);




    QPushButton *button1 = new QPushButton("cloud", &window);
    layout->addWidget(button1);

    QPushButton *button2 = new QPushButton("doc", &window);
    layout->addWidget(button2);

    QPushButton *button3 = new QPushButton("Почта", &window);
    layout->addWidget(button3);

    QPushButton *button4 = new QPushButton("Задачник", &window);
    layout->addWidget(button4);

    //https://cloud.phoenix-ekb.ru
    QObject::connect(button1, &QPushButton::clicked, [webView]() {
        webView->setUrl(QUrl("https://cloud.phoenix-ekb.ru"));

        //webView->load(QUrl("https://cloud.phoenix-ekb.ru"));
        //webView->show();
    });

    //https://doc.phoenix-ekb.ru
    QObject::connect(button2, &QPushButton::clicked, [webView]() {
        webView->setUrl(QUrl("https://doc.phoenix-ekb.ru"));
        // webView->setPage(new UserAgentWebPage("https://doc.phoenix-ekb.ru"));
    });

    QObject::connect(button3, &QPushButton::clicked, [webView]() {
        webView->setUrl(QUrl("https://fox8.ru"));
    });

    QObject::connect(button4, &QPushButton::clicked, [webView]() {
        webView->setUrl(QUrl("https://fnx1.ru"));
    });






    window.show();

    return app.exec();
}
web4/web4.pro

Код: Выделить всё

QT       += core gui
QT += webkit webkitwidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

TRANSLATIONS += \
    web4_ru_RU.ts

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

Re: qt

Сообщение ya »

test: Кастомный веб-браузер v2

main.cpp

Код: Выделить всё

#include <QApplication>
#include <QProcess>
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include <QWebEngineView>
#include <QString>
#include <QWebEngineProfile>
#include <QtWebEngine>

int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWidget window;
    window.setWindowTitle("Запуск другой программы");
    window.resize(1600, 900);

    QVBoxLayout *layout = new QVBoxLayout(&window);

    QWebEngineView *webView = new QWebEngineView();
    layout->addWidget(webView);

    // Устанавливаем свой UserAgent
    QWebEngineProfile *profile = webView->page()->profile();
    profile->setHttpUserAgent("Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.121 Safari/535.2");

    // Загружаем стартовую страницу
    webView->load(QUrl("https://www.google.com"));

    QPushButton *button1 = new QPushButton("cloud", &window);
    layout->addWidget(button1);

    QPushButton *button2 = new QPushButton("doc", &window);
    layout->addWidget(button2);

    QPushButton *button3 = new QPushButton("Почта", &window);
    layout->addWidget(button3);

    QPushButton *button4 = new QPushButton("Задачник", &window);
    layout->addWidget(button4);

    //https://cloud.phoenix-ekb.ru
    QObject::connect(button1, &QPushButton::clicked, [webView]() {
        webView->load(QUrl("https://cloud.phoenix-ekb.ru"));
    });

    //https://doc.phoenix-ekb.ru
    QObject::connect(button2, &QPushButton::clicked, [webView]() {
        webView->load(QUrl("https://doc.phoenix-ekb.ru"));
    });

    QObject::connect(button3, &QPushButton::clicked, [webView]() {
        webView->load(QUrl("https://fox8.ru"));
    });

    QObject::connect(button4, &QPushButton::clicked, [webView]() {
        webView->load(QUrl("https://fnx1.ru"));
    });

    window.show();

    return app.exec();
}

web4.pro

Код: Выделить всё

QT       += core gui
QT += webkit webkitwidgets
QT += webengine
QT += webenginewidgets

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

TRANSLATIONS += \
    web4_ru_RU.ts

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

Re: qt

Сообщение ya »

test: Кастомный веб-браузер v3

Список необходимых библиотек для компиляции:
Qt WebEngine или https://code.qt.io/cgit/qt/qtwebengine-chromium.git/ qt/qtwebengine-chromium.git
Qt Webkit
Qt Web View

main.cpp

Код: Выделить всё

#include <QApplication>
#include <QProcess>
#include <QWidget>
#include <QVBoxLayout>
#include <QPushButton>
#include <QWebEngineView>
#include <QString>
#include <QWebEngineProfile>
#include <QtWebEngine>
#include <QSsl>
#include <QSslCertificate>
#include <QSslCertificateExtension>
#include <QCache>
#include <QtWebEngineWidgets>
#include <QWebEngineSettings>
#include <GL/gl.h>
#include <QWebEngineHttpRequest>

#include <QSslConfiguration>
#include <QFile>


//test: перехватывать события мыши в webengineview
/*
class CustomWebEngineView: public QWebEngineView {
public:
    explicit CustomWebEngineView(QWidget *parent = nullptr): QWebEngineView(parent) {
        QApplication::instance()->installEventFilter(this);
        setMouseTracking(true);
    }

protected:
    bool eventFilter(QObject *object, QEvent *event) {
        if (object->parent() == this && event->type() == QEvent::MouseMove) {
            mouseMoveEvent(static_cast<QMouseEvent *>(event));
        }

        return false;
    }
}; */

QUrl commandLineUrlArgument()
{
    const QStringList args = QCoreApplication::arguments();
    for (const QString &arg : args.mid(1)) {
        if (!arg.startsWith(QLatin1Char('-')))
            return QUrl::fromUserInput(arg);
    }
    return QUrl(QStringLiteral("https://www.qt.io"));
}


class CustomWebPage : public QWebEnginePage
{
public:
    virtual bool certificateError(const QWebEngineCertificateError &/*error*/)
    {
        return true;
    }
};

int main(int argc, char *argv[])
{



// Устанавливаем корневой сертификат SSL
QFile certFile("/etc/ssl/certs/Microsoft_RSA_Root_Certificate_Authority_2017.pem"); // Путь к вашему корневому сертификату
if (certFile.open(QIODevice::ReadOnly)) {
    QSslCertificate certificate(&certFile, QSsl::Pem);
    if (!certificate.isNull()) {
        QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration();
        QList<QSslCertificate> caCerts = sslConfig.caCertificates();
        caCerts.append(certificate);
        sslConfig.setCaCertificates(caCerts);
        QSslConfiguration::setDefaultConfiguration(sslConfig);
    } else {
        qDebug() << "Failed to load certificate";
    }
} else {
    qDebug() << "Failed to open certificate file";
}




    QCoreApplication::setOrganizationName("QtExamples");
    QCoreApplication::setAttribute(Qt::AA_ShareOpenGLContexts);
    QtWebEngine::initialize();


    //QGuiApplication app(argc, argv);


    //QtWebEngineQuick::initialize();
    QApplication app(argc, argv);

//    QQmlApplicationEngine engine;
//    engine.load(QUrl("https://doc.phoenix-ekb.ru/"));
   // engine.rootContext()->setContextProperty("dataSource", dataSource);
/*
    if (engine.rootObjects().isEmpty())
    {
        return -1;
    }
*/


    QWidget window;
    window.setWindowTitle("Phoenix portal");
    window.resize(1600, 900);
    //const QSize BUTTON_SIZE = QSize(122, 22);

    // Разместит все элементы вертикально
    QVBoxLayout *layout = new QVBoxLayout(&window);
    // Разместит все элементы горизонтально
    //QBoxLayout *layout1 = new QHBoxLayout();
    // Разместит все элементы горизонтально
//    QHBoxLayout *layout1 = new QHBoxLayout();
    //layout->addWidget(layout1);



    QWebEngineView *webView = new QWebEngineView();
    layout->addWidget(webView);

//    CustomWebPage *webpage;
    webView->setPage(new CustomWebPage());
    //webView->setPage(webpage);


    // Устанавливаем свой UserAgent
    QWebEngineProfile *profile = webView->page()->profile();
    profile->clearHttpCache();
    profile->setHttpUserAgent("Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36");
    profile->setHttpAcceptLanguage("ru");
    profile->setUseForGlobalCertificateVerification(true);



    webView->settings()->setAttribute(QWebEngineSettings::ErrorPageEnabled, true);
    webView->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
    webView->settings()->setAttribute(QWebEngineSettings::JavascriptCanOpenWindows, true);
    webView->settings()->setAttribute(QWebEngineSettings::LocalStorageEnabled, true);
    webView->settings()->setAttribute(QWebEngineSettings::XSSAuditingEnabled, true);
    webView->settings()->setAttribute(QWebEngineSettings::LocalContentCanAccessRemoteUrls, true);

    /*
    webView->setUrlRequestInterceptor([](QWebEngineUrlRequestInfo &info) {
        QUrl url = info.requestUrl();

        //if (url.toString() == "https://www.example.com") {
            info.setHttpHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36");
        //}
    });
    */

    //test
    //webView->page()->loadFinished(true);
    //webView->normalGeometry();
    //webView->acceptDrops();
    //webView->setShortcutEnabled(true);



    // Загружаем стартовую страницу
    webView->load(QUrl(QStringLiteral("https://doc.phoenix-ekb.ru/")));

    QPushButton *button1 = new QPushButton("cloud", &window);
  //  button1->setFixedSize(BUTTON_SIZE);
 //   button1->setGeometry(100, 100, 50, 50);
    layout->addWidget(button1);

    QPushButton *button2 = new QPushButton("doc", &window);
 //   button2->setFixedSize(BUTTON_SIZE);
 //   button2->geometry().bottomLeft();
    layout->addWidget(button2);

    QPushButton *button3 = new QPushButton("Почта", &window);
 //   button3->setFixedSize(BUTTON_SIZE);
    layout->addWidget(button3);

    QPushButton *button4 = new QPushButton("Задачник", &window);
  //  button4->setFixedSize(BUTTON_SIZE);
    layout->addWidget(button4);



    //https://cloud.phoenix-ekb.ru
    QObject::connect(button1, &QPushButton::clicked, [webView]() {
        webView->load(QUrl(QStringLiteral("https://cloud.phoenix-ekb.ru")));
    });

    //https://doc.phoenix-ekb.ru
    QObject::connect(button2, &QPushButton::clicked, [webView]() {
        webView->load(QUrl(QStringLiteral("https://doc.phoenix-ekb.ru")));
        //webView->page()->runJavaScript("alert('Hello from JavaScript!')");
    });

    QObject::connect(button3, &QPushButton::clicked, [webView]() {
        webView->load(QUrl(QStringLiteral("https://fox8.ru")));
    });

    QObject::connect(button4, &QPushButton::clicked, [webView]() {
        webView->load(QUrl(QStringLiteral("https://fnx1.ru")));
    });


    window.show();

    return app.exec();

}



web4.pro

Код: Выделить всё

QT       += core gui
QT += webkit webkitwidgets
QT += webengine
QT += webenginewidgets
QT += webenginecore

greaterThan(QT_MAJOR_VERSION, 4): QT += webkit webkitwidgets webengine widgets webenginewidgets

CONFIG += c++11
CONFIG += qml_debug

# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

FORMS += \
    mainwindow.ui

TRANSLATIONS += \
    web4_ru_RU.ts

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

Re: qt

Сообщение ya »

ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

Re: qt

Сообщение ya »

веб-браузер на visual studio
https://github.com/MicrosoftEdge/WebView2Samples
Вложения
WPF_GettingStarted-2024.07.22_10-07.zip
(56.08 МБ) 1484 скачивания
WPF_GettingStarted-2024.07.22_10-07.zip
(56.08 МБ) 1484 скачивания
ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

Re: qt

Сообщение ya »

веб-браузер на visual studio v2
WPF_GettingStarted-2024.07.24_10-27.zip
(81.41 МБ) 1538 скачиваний
WPF_GettingStarted-2024.07.24_10-27.zip
(81.41 МБ) 1538 скачиваний

MainWindow.xaml.cs

Код: Выделить всё

using Microsoft.Web.WebView2.Core;
using Microsoft.Web.WebView2.WinForms;
using System;
using System.Collections.Concurrent;
using System.Windows;
using System.Windows.Controls;
using System.Buffers.Binary;

//using System.Windows;
using Microsoft.Web.WebView2.Wpf;


namespace WPFSample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// 
    
    /// </summary>
    public partial class MainWindow : Window
    {

       // DockPanel myDockPanel = new DockPanel();
           

        public MainWindow()
        {
            InitializeComponent();
            // await webView.EnsureCoreWebView2Async();
            // CoreWebView2.EnsureCoreWebView2Async();
            webView.NavigationStarting += EnsureHttps;
            InitializeAsync();

           // myDockPanel.Children.Add(webView);
           // myDockPanel.Children.Add(webView_cloud);

        }

        async void InitializeAsync()
        {
            await webView.EnsureCoreWebView2Async(null);
            webView.CoreWebView2.WebMessageReceived += UpdateAddressBar;

            await webView.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync("window.chrome.webview.postMessage(window.document.URL);");
            //await webView.CoreWebView2.AddScriptToExecuteOnDocumentCreatedAsync("window.chrome.webview.addEventListener(\'message\', event => alert(event.data));");

        }

        void UpdateAddressBar(object sender, CoreWebView2WebMessageReceivedEventArgs args)
        {
            String uri = args.TryGetWebMessageAsString();
            addressBar.Text = uri;
            webView.CoreWebView2.PostWebMessageAsString(uri);
        }

        void EnsureHttps(object sender, CoreWebView2NavigationStartingEventArgs args)
        {
            String uri = args.Uri;
            if (!uri.StartsWith("https://"))
            {
                webView.CoreWebView2.ExecuteScriptAsync($"alert('{uri} is not safe, try an https link')");
                args.Cancel = true;
            }
        }

        private void ButtonGo_Click(object sender, RoutedEventArgs e)
        {
            if (webView != null && webView.CoreWebView2 != null)
            {
                dp0.Children.Remove(webView);
                dp0.Children.Add(webView);
                webView.CoreWebView2.Navigate(addressBar.Text);
            }
        }

        private void Button_zadachnik(object sender, RoutedEventArgs e)
        {
            //webView.CoreWebView2.Navigate("https://fnx1.ru");
            dp0.Children.Remove(webView_zadachnik);
            dp0.Children.Add(webView_zadachnik);

        }

        private void Button_pochta(object sender, RoutedEventArgs e)
        {
            //webView.CoreWebView2.Navigate("https://fox8.ru");
            dp0.Children.Remove(webView_pochta);
            dp0.Children.Add(webView_pochta);

        }

        private void Button_cloud(object sender, RoutedEventArgs e)
        {
            //webView.CoreWebView2.Navigate("https://cloud.phoenix-ekb.ru");
            //webView.CoreWebView2.BringToFront();
            //webView_cloud.CoreWebView2.Navigate("https://cloud.phoenix-ekb.ru");
            //webView_cloud.child.BringToFront();
            //webView_cloud.BringToFront();
            //Panel.SetZIndex(webView_cloud, 0); // где myWebView2 - это ваш объект WebView2
            //Window.SetZIndex(webView_cloud, 0); // где myWebView2 - это ваш объект WebView2
            //Grid.SetZIndex(webView_cloud, 1);
            //gr001.SetZIndex(webView_cloud, 0);
            //Grid.SetZIndex(webView, 0);
            //Parent.SetZIndex(webView_cloud, 0);
            //we3.SetZIndex(webView_cloud, 0);
            //Panel.SetZIndex(webView_cloud, 0);

            //Panel.SetZIndex(webView_cloud, 0);
            // Panel.SetZIndex(webView, 1);

            // Panel.SetZIndex(webView_cloud, 111);

            dp0.Children.Remove(webView_cloud);          
            dp0.Children.Add(webView_cloud);

              //           dp0.Children.Insert(0, webView_cloud);
              //myDockPanel.Children.Remove(webView_cloud);
            //myDockPanel.Children.Insert(0, webView_cloud);

        }

        private void Button_elma(object sender, RoutedEventArgs e)
        {
            //webView.CoreWebView2.Navigate("https://doc.phoenix-ekb.ru");
            //Grid.SetZIndex(webView, 0);

            dp0.Children.Remove(webView_elma);
            dp0.Children.Add(webView_elma);

        }

        private void Button_google(object sender, RoutedEventArgs e)
        {
            dp0.Children.Remove(webView);
            dp0.Children.Add(webView);
        }
    }
}

MainWindow.xaml

Код: Выделить всё

    <Window x:Class="WPFSample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:local="clr-namespace:WPFSample"
        xmlns:wv2="clr-namespace:Microsoft.Web.WebView2.Wpf;assembly=Microsoft.Web.WebView2.Wpf" xmlns:Grid="http://schemas.microsoft.com/netfx/2009/xaml/presentation"
        mc:Ignorable="d"
        Title="MainWindow" Height="700" Width="1300">

    <DockPanel>

        <DockPanel DockPanel.Dock="Top">
            <Button Content="Задачник" Width="NaN" HorizontalAlignment="Left" Click="Button_zadachnik" Margin="5,0,0,0"/>
            <Button Content="Почта" Width="NaN" HorizontalAlignment="Left" Margin="5,0,0,0" Click="Button_pochta"/>
            <Button Content="Клауд" Width="39.624" HorizontalAlignment="Left" Click="Button_cloud" Margin="5,0,0,0"/>
            <Button Content="Эльма" Width="NaN" HorizontalAlignment="Left" Margin="5,0,0,0" Click="Button_elma"/>
            <Button Content="Гугл" Width="NaN" HorizontalAlignment="Left" Margin="5,0,0,0" Click="Button_google"/>
            <TextBox x:Name="addressBar" TextWrapping="NoWrap" Margin="5,0,0,0" Width="1000"/>
            
             <Button x:Name="ButtonGo"
            DockPanel.Dock="Right"
            Click="ButtonGo_Click"
            Content="Go" Margin="5,0,0,0" Width="45" HorizontalAlignment="Left"
        />
        </DockPanel>



        <DockPanel Name="dp0">

            <wv2:WebView2 x:Name="webView_zadachnik" 
                  Source="https://fnx1.ru"
      >
                <wv2:WebView2.CreationProperties>
                    <wv2:CoreWebView2CreationProperties/>
                </wv2:WebView2.CreationProperties>
            </wv2:WebView2>


            <wv2:WebView2 x:Name="webView_pochta" 
                   Source="https://fox8.ru"
       >
                <wv2:WebView2.CreationProperties>
                    <wv2:CoreWebView2CreationProperties/>
                </wv2:WebView2.CreationProperties>
            </wv2:WebView2>


            <wv2:WebView2 x:Name="webView_elma" 
                    Source="https://doc.phoenix-ekb.ru"
        >
                <wv2:WebView2.CreationProperties>
                    <wv2:CoreWebView2CreationProperties/>
                </wv2:WebView2.CreationProperties>
            </wv2:WebView2>



            <wv2:WebView2 x:Name="webView_cloud" 
                    Source="https://cloud.phoenix-ekb.ru"
        >
                <wv2:WebView2.CreationProperties>
                    <wv2:CoreWebView2CreationProperties/>
                </wv2:WebView2.CreationProperties>
              </wv2:WebView2>
            
           
            <wv2:WebView2 x:Name="webView"
                  Source="https://google.com" 
        >
                <wv2:WebView2.CreationProperties>
                    <wv2:CoreWebView2CreationProperties/>
                </wv2:WebView2.CreationProperties>
            </wv2:WebView2>
       </DockPanel>





    </DockPanel>

</Window>

ya
^-^
Сообщения: 2534
Зарегистрирован: 16 дек 2021, 19:56

Re: qt

Сообщение ya »

веб-браузер на visual studio v3
Вложения
WPF_GettingStarted-2024.07.24_11-31.zip
(99.12 МБ) 1511 скачиваний
WPF_GettingStarted-2024.07.24_11-31.zip
(99.12 МБ) 1511 скачиваний
Ответить