Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Why can't ie11 load the DLL generated by the qt-5.6/activeqt-hierarchy-example?
Forum Updated to NodeBB v4.3 + New Features

Why can't ie11 load the DLL generated by the qt-5.6/activeqt-hierarchy-example?

Scheduled Pinned Locked Moved Solved General and Desktop
27 Posts 3 Posters 1.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    mirro
    wrote on last edited by
    #1

    https://doc.qt.io/archives/qt-5.6/activeqt-activeqt-hierarchy-example.html
    //Use the QAxWidget program to verify that it can be loaded.
    //IE11Security Settings for activex have been turned off,IE11 still cannot load.

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Just tried on Qt 32-bit version 5.7.1 for MSVC 2013 on my Windows 7 PC and it works for me, so I think it should work for you on Qt version 5.6.
      Here's what I did:

      1. Built the .dll in Release mode, so now I have the .dll in C:\Qt\Examples\Qt-5.7\activeqt\build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release\release

      2. I opened a Qt 5.7 MSVC2013 CMD window and run windeployqt:

      C:\Qt\Examples\Qt-5.7\activeqt\build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release\release>windeployqt hierarchyax.dll
      C:\Qt\Examples\Qt-5.7\activeqt\build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-R
      elease\release\hierarchyax.dll 32 bit, release executable
      Adding Qt5Svg for qsvgicon.dll
      Direct dependencies: Qt5Core Qt5Gui Qt5Widgets
      All dependencies   : Qt5Core Qt5Gui Qt5Widgets
      To be deployed     : Qt5Core Qt5Gui Qt5Svg Qt5Widgets
      Warning: Cannot find Visual Studio installation directory, VCINSTALLDIR is not set.
      Updating Qt5Core.dll.
      Updating Qt5Gui.dll.
      Updating Qt5Svg.dll.
      Updating Qt5Widgets.dll.
      Updating libGLESV2.dll.
      Updating libEGL.dll.
      Updating D3Dcompiler_47.dll.
      Updating opengl32sw.dll.
      Patching Qt5Core.dll...
      Creating directory C:/Qt/Examples/Qt-5.7/activeqt/build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release/release/iconengines.
      Updating qsvgicon.dll.
      Creating directory C:/Qt/Examples/Qt-5.7/activeqt/build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release/releas/imageformats.
      Updating qdds.dll.
      Updating qgif.dll.
      Updating qicns.dll.
      Updating qico.dll.
      Updating qjpeg.dll.
      Updating qsvg.dll.
      Updating qtga.dll.
      Updating qtiff.dll.
      Updating qwbmp.dll.
      Updating qwebp.dll.
      Creating directory C:/Qt/Examples/Qt-5.7/activeqt/build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release/release/platforms.
      Updating qwindows.dll.
      Creating C:\Qt\Examples\Qt-5.7\activeqt\build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release\release\translations...
      Creating qt_ca.qm...
      Creating qt_cs.qm...
      Creating qt_de.qm...
      Creating qt_en.qm...
      Creating qt_fi.qm...
      Creating qt_fr.qm...
      Creating qt_he.qm...
      Creating qt_hu.qm...
      Creating qt_it.qm...
      Creating qt_ja.qm...
      Creating qt_ko.qm...
      Creating qt_lv.qm...
      Creating qt_pl.qm...
      Creating qt_ru.qm...
      Creating qt_sk.qm...
      Creating qt_uk.qm...
      
      1. To check that the ActiveX .dll can launch, in the same CMD window I typed:
      regsvr32 hierarchyax.dll
      

      If you get a confirmation dialog box (and no errors) that means windeployqt above was a success and the .dll can be launched by IE11.

      1. Then I took the .html code from https://doc.qt.io/archives/qt-5.6/activeqt-activeqt-hierarchy-example.html and edited it to this:
      <script language="javascript">
      function createSubWidget( form )
      {
          ParentWidget.createSubWidget( form.nameEdit.value );
      }
      
      function renameSubWidget( form )
      {
          var SubWidget = ParentWidget.subWidget( form.nameEdit.value );
          if ( !SubWidget ) {
              alert( "No such widget " + form.nameEdit.value + "!" );
              return;
          }
          SubWidget.label = form.labelEdit.value;
          form.nameEdit.value = SubWidget.label;
      }
      
      function setFont( form )
      {
          ParentWidget.font = form.fontEdit.value;
      }
      </script>
      
      <p>
      This widget can have many children!
      </p>
      <object ID="ParentWidget" CLASSID="CLSID:d574a747-8016-46db-a07c-b2b4854ee75c"
      CODEBASE="C:\Qt\Examples\Qt-5.7\activeqt\build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release\release\hierarchyax.dll">
      [Object not available! Did you forget to build and register the server?]
      </object><br />
      <form>
      <input type="edit" ID="nameEdit" value="&lt;enter object name&gt;" />
      <input type="button" value="Create" onClick="createSubWidget(this.form)" />
      <input type="edit" ID="labelEdit" />
      <input type="button" value="Rename" onClick="renameSubWidget(this.form)" />
      <br />
      <input type="edit" ID="fontEdit" value="MS Sans Serif" />
      <input type="button" value = "Set Font" onClick="setFont(this.form)" />
      </form>
      

      (Note: I only changed the CODEBASE line)
      I saved this (in the same directory as the hierarchyax.dll) as a file test.html

      1. I opened IE11 so it shows en empty window and a File Explorer, then I drag the test.html into the empty IE11 window.

      2. For the default settings for WIndows 7 (or anyway on my PC) now IE11 prompts at the bottom of the window (for about 10 seconds):
        "Internet Explorer has stopped this page from running a ActiveX-control"
        Click on the Allow button and say Yes.
        (Also you can try to change the ActiveX security settings in IE11)

      3. Now you should see this contents in IE11, voila!
        Screenshot 2020-05-30 at 09.08.43.png

      Or if there was a problem somewhere, then you'll get this screen instead :-(
      Screenshot 2020-05-30 at 09.10.48.png

      Good luck!

      1 Reply Last reply
      2
      • M Offline
        M Offline
        mirro
        wrote on last edited by mirro
        #3

        @hskoglund said in Why can't ie11 load the DLL generated by the qt-5.6/activeqt-hierarchy-example?:

        Qt 32-bit version

        thank you, My activeQT is Qt 64-bit . Have you ever try to load activeQT for Qt 64-bit with IE11?

        1 Reply Last reply
        0
        • hskoglundH Offline
          hskoglundH Offline
          hskoglund
          wrote on last edited by
          #4

          Hmm, 64-bit should be possible, but I've never tried :-)

          If step 3. regsvr32 hierarchyax.dll succeeds for you when the .dll is 64-bit flavored, then in theory IE11 should be able to load it too.

          Googled a bit, found this: https://stackoverflow.com/questions/42378018/how-to-load-64-bit-activex-control-in-64-bit-ie-version-11

          M 1 Reply Last reply
          3
          • hskoglundH hskoglund

            Hmm, 64-bit should be possible, but I've never tried :-)

            If step 3. regsvr32 hierarchyax.dll succeeds for you when the .dll is 64-bit flavored, then in theory IE11 should be able to load it too.

            Googled a bit, found this: https://stackoverflow.com/questions/42378018/how-to-load-64-bit-activex-control-in-64-bit-ie-version-11

            M Offline
            M Offline
            mirro
            wrote on last edited by mirro
            #5

            @hskoglund ie11 successfully load activeQT for Qt 64-bit. To start the ie11 64-bit .
            Using javascript:alert(navigator.userAgent) Command view ie11 versions info.

            How do you assign to an objectID constructor parameter in the html5 , please?

            osgActiveQT::osgActiveQT(QWidget *parent, int width, int height)///osgActiveQT objectid constructor function
            : QWidget(parent),_widthSize(width),_heightSize(height)
            {
            ui.setupUi(this);
            createOsgScene();
            }

            <object ID="osgActiveQT" WIDTH="900" HEIGHT="600" CLASSID="CLSID:8F2F265B-11DC-49C0-91AA-26263E1F3B7C"
            CODEBASE="http://www.qt-project.org/demos/hierarchy.cab">
            [Object not available! Did you forget to build and register the server?]
            </object>

            1 Reply Last reply
            0
            • hskoglundH Offline
              hskoglundH Offline
              hskoglund
              wrote on last edited by
              #6

              Hi, you mean you want to show the .html page with the hierarchyax.dll in IE11 programmatically using C++ code in Qt, i.e. not showing it by opening the .html file by hand?

              It used to be possible to inject .html code into IE through COM/ActiveQt and a Browser Helper Object, but they are I think forbidden to use nowadays due to security.

              One crude but simple way could be write a new .html file using a QFile in your constructor, changing the code to for width, height etc. e.g. QString("object ID="osgActiveQT" WIDTH="%1" HEIGHT="%2"...)
              Then save the file and start an IE11 instance through QProcess, say like:
              QProcess::startDetached("C:\\Program Files\\Internet Explorer\\iexplore.exe",QStringList("C:\\location of your .html file"));

              M 1 Reply Last reply
              0
              • hskoglundH hskoglund

                Hi, you mean you want to show the .html page with the hierarchyax.dll in IE11 programmatically using C++ code in Qt, i.e. not showing it by opening the .html file by hand?

                It used to be possible to inject .html code into IE through COM/ActiveQt and a Browser Helper Object, but they are I think forbidden to use nowadays due to security.

                One crude but simple way could be write a new .html file using a QFile in your constructor, changing the code to for width, height etc. e.g. QString("object ID="osgActiveQT" WIDTH="%1" HEIGHT="%2"...)
                Then save the file and start an IE11 instance through QProcess, say like:
                QProcess::startDetached("C:\\Program Files\\Internet Explorer\\iexplore.exe",QStringList("C:\\location of your .html file"));

                M Offline
                M Offline
                mirro
                wrote on last edited by mirro
                #7

                @hskoglund

                connect(ui.screenButton, SIGNAL(clicked()), this, SLOT(resetWindowSize()));

                so I want to respond to the signal sent by an activeQT button on the javascript.What to do?

                1 Reply Last reply
                0
                • hskoglundH Offline
                  hskoglundH Offline
                  hskoglund
                  wrote on last edited by
                  #8

                  If you look in the Hiierarchy example, there are already some signals sent from Javascript to the C++ code, for example this line in Javascript:

                  function createSubWidget( form )
                  {
                      ParentWidget.createSubWidget( form.nameEdit.value );
                  }
                  

                  which arrives to this C++ code in objects.cpp:

                  void QParentWidget::createSubWidget(const QString &name)
                  {
                      QSubWidget *sw = new QSubWidget(this, name);
                      m_vbox->addWidget(sw);
                      sw->setLabel(name);
                      sw->show();
                  }
                  

                  So if you want to implement your own signal in Javascript to a slot in C++ try to copy that example...

                  M 1 Reply Last reply
                  0
                  • hskoglundH hskoglund

                    If you look in the Hiierarchy example, there are already some signals sent from Javascript to the C++ code, for example this line in Javascript:

                    function createSubWidget( form )
                    {
                        ParentWidget.createSubWidget( form.nameEdit.value );
                    }
                    

                    which arrives to this C++ code in objects.cpp:

                    void QParentWidget::createSubWidget(const QString &name)
                    {
                        QSubWidget *sw = new QSubWidget(this, name);
                        m_vbox->addWidget(sw);
                        sw->setLabel(name);
                        sw->show();
                    }
                    

                    So if you want to implement your own signal in Javascript to a slot in C++ try to copy that example...

                    M Offline
                    M Offline
                    mirro
                    wrote on last edited by mirro
                    #9

                    @hskoglund said in Why can't ie11 load the DLL generated by the qt-5.6/activeqt-hierarchy-example?:

                    So if you want to implement your own signal in Javascript to a slot in C++ try to copy that example...

                    sorry,I want to implement own slot in Javascript to a signal in C++. What to do?

                    1 Reply Last reply
                    0
                    • hskoglundH Offline
                      hskoglundH Offline
                      hskoglund
                      wrote on last edited by hskoglund
                      #10

                      Aha, you mean you want the other way around? Start with C++ in Qt, emit a signal from there into IE11, which will then launch some Javascript code?

                      It's supported by ActiveQt, you just use the normal signals: keyword, let's add a timeout event to the hiearchy example above:

                      to communicate with the Javascript code you can declare C++ variables using the Q_PROPERTY keyword.
                      So at the top of objects.h I added a timer timeout variable:

                      ...
                      class QParentWidget : public QWidget
                      {
                          Q_OBJECT
                      
                          Q_PROPERTY( int timeout READ timeout WRITE setTimeout )
                      
                          Q_CLASSINFO("ClassID", "{d574a747-8016-46db-a07c-b2b4854ee75c}");
                          Q_CLASSINFO("InterfaceID", "{4a30719d-d9c2-4659-9d16-67378209f822}");
                          Q_CLASSINFO("EventsID", "{4a30719d-d9c2-4659-9d16-67378209f823}");
                      public:
                          QParentWidget(QWidget *parent = 0);
                      
                          QSize sizeHint() const;
                          int timeout() const { return 0; };      // dummy (not used)
                      
                      signals:
                          void signalFromQt(QString);
                      
                      public slots:
                          void createSubWidget( const QString &name );
                          QSubWidget *subWidget( const QString &name );
                          void setTimeout( const int value);      // this one we call from Javascript
                      
                      private:
                          QVBoxLayout *vbox;
                      };
                      ...
                      

                      then in objects.cpp
                      I added #include "qtimer.h" and the setTimeout function:

                      ...
                      void QParentWidget::setTimeout(const int value)
                      {
                          static int i = 0;
                          QTimer::singleShot(value * 1000,[this] { signalFromQt("Hello no.:" + QString::number(++i)); });
                      }
                      ...
                      

                      finally I modifed test.html to this:

                      <script language="javascript">
                      function createSubWidget( form )
                      {
                          ParentWidget.createSubWidget( form.nameEdit.value );
                      }
                      
                      function renameSubWidget( form )
                      {
                          var SubWidget = ParentWidget.subWidget( form.nameEdit.value );
                          if ( !SubWidget ) {
                              alert( "No such widget " + form.nameEdit.value + "!" );
                              return;
                          }
                          SubWidget.label = form.labelEdit.value;
                          form.nameEdit.value = SubWidget.label;
                      }
                      
                      function setTimeout( form )
                      {
                          ParentWidget.timeout = form.timerEdit.value;
                      }
                      </script>
                      
                      <p>
                      This widget can have many children!
                      </p>
                      <object ID="ParentWidget" CLASSID="CLSID:d574a747-8016-46db-a07c-b2b4854ee75c"
                      CODEBASE="C:\Qt\Examples\Qt-5.7\activeqt\build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release\release\hierarchyax.dll">
                      [Object not available! Did you forget to build and register the server?]
                      </object><br />
                      <form>
                      <input type="edit" ID="nameEdit" value="" />
                      <input type="button" value="Create" onClick="createSubWidget(this.form)" />
                      <input type="edit" ID="labelEdit" />
                      <input type="button" value="Rename" onClick="renameSubWidget(this.form)" />
                      <br />
                      <input type="edit" ID="timerEdit" value="2" />
                      <input type="button" value = "set Timeout" onClick="setTimeout(this.form)" />
                      </form>
                      
                      <script language="javascript">
                      function ParentWidget::signalFromQt( Message )
                      {
                          alert ("Got a signal from Qt: " + Message);
                      }
                      </script>
                      

                      I tossed the setFont() functionality and instead I added the "set Timeout" button. Every time you press it, the QTimer::singleShot will be armed and when it fires it will emit the signalFromQt() which is caught by the Javascript code ParentWidget::signalFromQt()

                      Edit: note that in the test.html file above, the Javascript code for the function ParentWidget::signalFromQt() is at the end, because it has to be placed after the object ID="ParentWidget".... html code ifor the signal to work and the alert box to be shown. Don't know if this is a bug or a feature :-)

                      M 1 Reply Last reply
                      1
                      • hskoglundH hskoglund

                        Aha, you mean you want the other way around? Start with C++ in Qt, emit a signal from there into IE11, which will then launch some Javascript code?

                        It's supported by ActiveQt, you just use the normal signals: keyword, let's add a timeout event to the hiearchy example above:

                        to communicate with the Javascript code you can declare C++ variables using the Q_PROPERTY keyword.
                        So at the top of objects.h I added a timer timeout variable:

                        ...
                        class QParentWidget : public QWidget
                        {
                            Q_OBJECT
                        
                            Q_PROPERTY( int timeout READ timeout WRITE setTimeout )
                        
                            Q_CLASSINFO("ClassID", "{d574a747-8016-46db-a07c-b2b4854ee75c}");
                            Q_CLASSINFO("InterfaceID", "{4a30719d-d9c2-4659-9d16-67378209f822}");
                            Q_CLASSINFO("EventsID", "{4a30719d-d9c2-4659-9d16-67378209f823}");
                        public:
                            QParentWidget(QWidget *parent = 0);
                        
                            QSize sizeHint() const;
                            int timeout() const { return 0; };      // dummy (not used)
                        
                        signals:
                            void signalFromQt(QString);
                        
                        public slots:
                            void createSubWidget( const QString &name );
                            QSubWidget *subWidget( const QString &name );
                            void setTimeout( const int value);      // this one we call from Javascript
                        
                        private:
                            QVBoxLayout *vbox;
                        };
                        ...
                        

                        then in objects.cpp
                        I added #include "qtimer.h" and the setTimeout function:

                        ...
                        void QParentWidget::setTimeout(const int value)
                        {
                            static int i = 0;
                            QTimer::singleShot(value * 1000,[this] { signalFromQt("Hello no.:" + QString::number(++i)); });
                        }
                        ...
                        

                        finally I modifed test.html to this:

                        <script language="javascript">
                        function createSubWidget( form )
                        {
                            ParentWidget.createSubWidget( form.nameEdit.value );
                        }
                        
                        function renameSubWidget( form )
                        {
                            var SubWidget = ParentWidget.subWidget( form.nameEdit.value );
                            if ( !SubWidget ) {
                                alert( "No such widget " + form.nameEdit.value + "!" );
                                return;
                            }
                            SubWidget.label = form.labelEdit.value;
                            form.nameEdit.value = SubWidget.label;
                        }
                        
                        function setTimeout( form )
                        {
                            ParentWidget.timeout = form.timerEdit.value;
                        }
                        </script>
                        
                        <p>
                        This widget can have many children!
                        </p>
                        <object ID="ParentWidget" CLASSID="CLSID:d574a747-8016-46db-a07c-b2b4854ee75c"
                        CODEBASE="C:\Qt\Examples\Qt-5.7\activeqt\build-hierarchy-Desktop_Qt_5_7_1_MSVC2013_32bit-Release\release\hierarchyax.dll">
                        [Object not available! Did you forget to build and register the server?]
                        </object><br />
                        <form>
                        <input type="edit" ID="nameEdit" value="" />
                        <input type="button" value="Create" onClick="createSubWidget(this.form)" />
                        <input type="edit" ID="labelEdit" />
                        <input type="button" value="Rename" onClick="renameSubWidget(this.form)" />
                        <br />
                        <input type="edit" ID="timerEdit" value="2" />
                        <input type="button" value = "set Timeout" onClick="setTimeout(this.form)" />
                        </form>
                        
                        <script language="javascript">
                        function ParentWidget::signalFromQt( Message )
                        {
                            alert ("Got a signal from Qt: " + Message);
                        }
                        </script>
                        

                        I tossed the setFont() functionality and instead I added the "set Timeout" button. Every time you press it, the QTimer::singleShot will be armed and when it fires it will emit the signalFromQt() which is caught by the Javascript code ParentWidget::signalFromQt()

                        Edit: note that in the test.html file above, the Javascript code for the function ParentWidget::signalFromQt() is at the end, because it has to be placed after the object ID="ParentWidget".... html code ifor the signal to work and the alert box to be shown. Don't know if this is a bug or a feature :-)

                        M Offline
                        M Offline
                        mirro
                        wrote on last edited by mirro
                        #11

                        @hskoglund hi~thank you again!
                        I can receive a signal from qt in javascript now. But there's a problem.
                        I'm sending a qt setTimeout() signal to change IE11 window size and ActiveQT window size.
                        What's wrong with the javascript ? Why doesn't it change window size ? the following code.

                        class osgActiveGLQT : public QWidget,public QAxBindable
                        {
                        	Q_OBJECT
                        	Q_PROPERTY(QString WindowSize READ getWindowSize WRITE setWindowSize)
                        public:
                        	osgActiveGLQT(QWidget *parent = 0);
                        	QSize sizeHint() const
                        	{
                        		return QWidget::sizeHint().expandedTo(QSize(100, 100));
                        	}
                        	QString getWindowSize() const
                        	{
                        		return _strWindowSize;
                        	} 
                        private:
                        	//Ui::osgActiveGLQTClass ui;
                        signals:
                        	void signalFromQt(QString);
                        
                        public slots:
                        	void setWindowSize(const QString &string);
                        	void resetWindowSize(const QString &string);
                        public slots:
                        	void setTimeout();// this one we call from Javascript
                        private:
                        	QString    _strWindowSize;
                        	bool       _isFullScreen;
                        private:
                        	QPushButton* _windowSizeButton;
                        };
                        
                        osgActiveGLQT::osgActiveGLQT(QWidget *parent)
                        	: QWidget(parent), _strWindowSize("0,0"), _isFullScreen(false)
                        {
                        	if (this->objectName().isEmpty())
                        		this->setObjectName(QStringLiteral("osgActiveGLQTClass"));
                        	//this->resize(900, 600);
                        	_windowSizeButton = new QPushButton(this);
                        	_windowSizeButton->setObjectName(QStringLiteral("windowSizeButton"));
                        	_windowSizeButton->setGeometry(QRect(10, 5, 75, 23));
                        	_windowSizeButton->setText(QString::fromLocal8Bit("FullWindow"));
                        	connect(_windowSizeButton, SIGNAL(clicked()), this, SLOT(setTimeout()));
                        }
                        
                        void osgActiveGLQT::setWindowSize(const QString &string)
                        {
                        	if (!requestPropertyChange("WindowSize"))
                        		return;
                        
                        	propertyChanged("WindowSize");
                        
                        	_strWindowSize = string;
                        	int curIndex = _strWindowSize.indexOf(",");
                        	QString wid  = _strWindowSize.mid(0, curIndex);
                        	QString hei  = _strWindowSize.mid(curIndex + 1, _strWindowSize.length());
                        	//
                        	//
                        	//resize(wid.toInt(), hei.toInt());
                        	//update();
                        }
                        //
                        void osgActiveGLQT::resetWindowSize(const QString &string)
                        {
                        	QString strWindowSize = string;
                        	int curIndex   = strWindowSize.indexOf(",");
                        	QString wid    = strWindowSize.mid(0, curIndex);
                        	QString hei    = strWindowSize.mid(curIndex + 1, strWindowSize.length());
                        	//
                        	//QMessageBox::information(this, "About QSimpleAX", strWindowSize);
                        
                        	//resize(wid.toInt(), hei.toInt());
                        	//update();
                        }
                        
                        void osgActiveGLQT::setTimeout()
                        {
                        	_isFullScreen = !_isFullScreen;
                        	if (_isFullScreen)
                        	{
                        		QRect rct = QApplication::desktop()->availableGeometry();
                        		static int screenWidth  = rct.width();
                        		static int screenHeight = rct.height();
                        		QTimer::singleShot(150, [this] { signalFromQt(QString::number(screenWidth) + "," + QString::number(screenHeight)); });
                        		_windowSizeButton->setText(QString::fromLocal8Bit("resetWindow"));
                        	}
                        	else
                        	{
                        		int curIndex = _strWindowSize.indexOf(",");
                        		QString wid  = _strWindowSize.mid(0, curIndex);
                        		QString hei  = _strWindowSize.mid(curIndex + 1, _strWindowSize.length());
                        		static int screenWidth  = wid.toInt();
                        		static int screenHeight = hei.toInt();
                        		QTimer::singleShot(150, [this] { signalFromQt(QString::number(screenWidth) + "," + QString::number(screenHeight)); });
                        		_windowSizeButton->setText(QString::fromLocal8Bit("fullWindow"));
                        	}
                        }
                        
                        <object ID ="osgActiveGLQT" HSPACE="0" VSPACE="0" WIDTH="900" HEIGHT="600" CLASSID="CLSID:B0545661-8607-43BA-A1C2-B43C0A93D976">
                        <PARAM NAME="WindowSize" VALUE ="900,600" />
                        [Object not available! Did you forget to build and register the server?]
                        </object>
                        
                        
                        <script language="javascript">
                        function osgActiveGLQT::signalFromQt( Message )
                        {
                            //alert ("Got a signal from Qt: " + Message);
                        	var curIndex = Message.indexOf(",");  //
                        	var widthFormQt  = Message.substr(0,curIndex);
                        	var heightFormQt = Message.substr(curIndex+1, Message.length);  //
                        	
                        	document.getElementById("osgActiveGLQT").style.WIDTH  = widthFormQt;
                        	document.getElementById("osgActiveGLQT").style.HEIGHT = heightFormQt;
                        	
                        	var IntwidthFormQt  = parseInt(widthFormQt);
                        	var IntheightFormQt = parseInt(heightFormQt);
                        	
                        	window.moveTo(0,0);//
                        	window.resizeTo(IntwidthFormQt,IntheightFormQt);//
                        	var strWindowSize = "window.resizeTo(" + widthFormQt + "," + heightFormQt + ");";
                        	
                        	//osgActiveGLQT.resetWindowSize(Message);
                        }
                        </script>
                         
                        
                        1 Reply Last reply
                        0
                        • hskoglundH Offline
                          hskoglundH Offline
                          hskoglund
                          wrote on last edited by
                          #12

                          Hmm, looked at your code, C++ seems ok, but the Javascript window resizing stuff I don't know, I'm not that good with Javascript.

                          If you put back that alert, does it work and show the correct message (width,height)?

                          If so, then perhaps you need some kind of update/refresh of the window at the end, so make the resizing visible.

                          M 1 Reply Last reply
                          0
                          • hskoglundH hskoglund

                            Hmm, looked at your code, C++ seems ok, but the Javascript window resizing stuff I don't know, I'm not that good with Javascript.

                            If you put back that alert, does it work and show the correct message (width,height)?

                            If so, then perhaps you need some kind of update/refresh of the window at the end, so make the resizing visible.

                            M Offline
                            M Offline
                            mirro
                            wrote on last edited by mirro
                            #13

                            @hskoglund I put back that alert, It shows the correct width and height.

                            How do I reset width and height styles of osgActiveGLQT in javascript?

                            <object ID ="osgActiveGLQT" HSPACE="0" VSPACE="0" WIDTH="900" HEIGHT="600" CLASSID="CLSID:B0545661-8607-43BA-A1C2-B43C0A93D976">
                            <PARAM NAME="WindowSize" VALUE ="900,600" />
                            [Object not available! Did you forget to build and register the server?]
                            </object>
                            
                            1 Reply Last reply
                            0
                            • hskoglundH Offline
                              hskoglundH Offline
                              hskoglund
                              wrote on last edited by
                              #14

                              Don't think it's possible to do in Javascript, but what I do know, is that it's pretty easy to change width and height of a QWidget (e.g. setGeometry(), same as in osgActiveGLQT's constructor)

                              So, easiest would be to implement 2 new slots in your C++ code for the osgActiveGLQT object, for example setHeight() and setWidth().
                              Then you could call those 2 functions from Javascript, in the same way you call setTimeout() now.

                              M 2 Replies Last reply
                              0
                              • hskoglundH hskoglund

                                Don't think it's possible to do in Javascript, but what I do know, is that it's pretty easy to change width and height of a QWidget (e.g. setGeometry(), same as in osgActiveGLQT's constructor)

                                So, easiest would be to implement 2 new slots in your C++ code for the osgActiveGLQT object, for example setHeight() and setWidth().
                                Then you could call those 2 functions from Javascript, in the same way you call setTimeout() now.

                                M Offline
                                M Offline
                                mirro
                                wrote on last edited by
                                #15

                                @hskoglund the following code successfully changes window size in javascript.

                                <script language="javascript">
                                function ResetWidget()
                                {
                                     var e1 = document.getElementById("ParentWidget");
                                     e1.style.width  = "1000px";
                                     e1.style.height = "800px";
                                }
                                </script>
                                
                                <object ID="ParentWidget" WIDTH="900" HEIGHT="600" CLASSID="CLSID:d574a747-8016-46db-a07c-b2b4854ee75c"
                                CODEBASE="http://www.qt-project.org/demos/hierarchy.cab">
                                [Object not available! Did you forget to build and register the server?]
                                </object><br />
                                <form>
                                <input type="button" value="ResetWidget" onClick="ResetWidget()" />
                                </form>
                                
                                1 Reply Last reply
                                0
                                • hskoglundH hskoglund

                                  Don't think it's possible to do in Javascript, but what I do know, is that it's pretty easy to change width and height of a QWidget (e.g. setGeometry(), same as in osgActiveGLQT's constructor)

                                  So, easiest would be to implement 2 new slots in your C++ code for the osgActiveGLQT object, for example setHeight() and setWidth().
                                  Then you could call those 2 functions from Javascript, in the same way you call setTimeout() now.

                                  M Offline
                                  M Offline
                                  mirro
                                  wrote on last edited by mirro
                                  #16

                                  Why is the activeQT window size wrong when i set window size injavascript?

                                  The following screenshots and code
                                  link text

                                  <object ID ="osgActiveGLQT" WIDTH = "900" HEIGHT = "600" CLASSID="CLSID:B0545661-8607-43BA-A1C2-B43C0A93D976">
                                  [Object not available! Did you forget to build and register the server?]
                                  </object>
                                  
                                  #ifndef ActiveQTOSGWidget_H
                                  #define ActiveQTOSGWidget_H
                                  
                                  #include <iostream>
                                  
                                  #include <QtWidgets/QWidget>
                                  #include <QtWidgets/QLayout>
                                  #include <QtWidgets/QApplication>
                                  #include <QtWidgets/QLCDNumber>
                                  #include <QTimer>
                                  #include <QMessageBox>
                                  
                                  #include <osgViewer/CompositeViewer>
                                  #include <osgViewer/ViewerEventHandlers>
                                  #include <osgGA/MultiTouchTrackballManipulator>
                                  #include <osgDB/ReadFile>
                                  #include <osgQt/GraphicsWindowQt>
                                  #include <osg/PolygonOffset>
                                  
                                  class ActiveQTOSGWidget : public QWidget
                                  {
                                  public:
                                  	ActiveQTOSGWidget(QWidget *parent = 0);
                                  public:
                                  	virtual void paintEvent(QPaintEvent* event)
                                  	{
                                  		// Update the camera
                                  		QPainter paint(this);
                                  		QPen pen;
                                  		pen.setColor(QColor(255, 0, 0));
                                  		QBrush brush(QColor(255, 0, 0));
                                  		paint.setPen(pen);
                                  		paint.setBrush(brush);
                                  		int ss = width();
                                  		paint.drawRect(0, 0, width(), height());
                                  	}
                                  };
                                  #endif // OSGVIEW_H
                                  
                                  #ifndef OSGACTIVEGLQT_H
                                  #define OSGACTIVEGLQT_H
                                  #include <iostream>
                                  
                                  #include <QtWidgets/QWidget>
                                  #include <ActiveQt/QAxBindable>
                                  #include <QtWidgets/QLayout>
                                  #include <QtWidgets/QApplication>
                                  #include <QtWidgets/QLCDNumber>
                                  #include <QTimer>
                                  #include <QApplication>
                                  #include <QDesktopWidget>
                                  #include <QMessageBox>
                                  #include <QPushButton>
                                  
                                  #include "ui_osgactiveglqt.h"
                                  
                                  #include "ActiveQTOSGWidget.h"
                                  
                                  class osgActiveGLQT : public QWidget,public QAxBindable
                                  {
                                  	Q_OBJECT
                                  public:
                                  	osgActiveGLQT(QWidget *parent = 0);
                                  private:
                                  	Ui::osgActiveGLQTClass ui;
                                  };
                                  
                                  #endif // OSGACTIVEGLQT_H
                                  1 Reply Last reply
                                  0
                                  • hskoglundH Offline
                                    hskoglundH Offline
                                    hskoglund
                                    wrote on last edited by
                                    #17

                                    Nice! Resizing is most likely is part of the ActiveX specification, and ActiveQt being of good quality supports it.

                                    M 1 Reply Last reply
                                    0
                                    • hskoglundH hskoglund

                                      Nice! Resizing is most likely is part of the ActiveX specification, and ActiveQt being of good quality supports it.

                                      M Offline
                                      M Offline
                                      mirro
                                      wrote on last edited by mirro
                                      #18

                                      @hskoglund

                                      Is... there? Why is the activeQT window's size less than QT Createor window's size when I set the size of 'WIDTH' and 'HEIGHT' Properties of ActiveQT Object in javascript?

                                      The following screenshots and code
                                      link text

                                      <object ID ="osgActiveGLQT" WIDTH = "900" HEIGHT = "600" CLASSID="CLSID:B0545661-8607-43BA-A1C2-B43C0A93D976">
                                      [Object not available! Did you forget to build and register the server?]
                                      </object>
                                      
                                      #ifndef ActiveQTOSGWidget_H
                                      #define ActiveQTOSGWidget_H
                                      
                                      #include <iostream>
                                      
                                      #include <QtWidgets/QWidget>
                                      #include <QtWidgets/QLayout>
                                      #include <QtWidgets/QApplication>
                                      #include <QtWidgets/QLCDNumber>
                                      #include <QTimer>
                                      #include <QMessageBox>
                                      
                                      #include <osgViewer/CompositeViewer>
                                      #include <osgViewer/ViewerEventHandlers>
                                      #include <osgGA/MultiTouchTrackballManipulator>
                                      #include <osgDB/ReadFile>
                                      #include <osgQt/GraphicsWindowQt>
                                      #include <osg/PolygonOffset>
                                      
                                      class ActiveQTOSGWidget : public QWidget
                                      {
                                      public:
                                      	ActiveQTOSGWidget(QWidget *parent = 0);
                                      public:
                                      	virtual void paintEvent(QPaintEvent* event)
                                      	{
                                      		// Update the camera
                                      		QPainter paint(this);
                                      		QPen pen;
                                      		pen.setColor(QColor(255, 0, 0));
                                      		QBrush brush(QColor(255, 0, 0));
                                      		paint.setPen(pen);
                                      		paint.setBrush(brush);
                                      		int ss = width();
                                      		paint.drawRect(0, 0, width(), height());
                                      	}
                                      };
                                      #endif // OSGVIEW_H
                                      
                                      #ifndef OSGACTIVEGLQT_H
                                      #define OSGACTIVEGLQT_H
                                      #include <iostream>
                                      
                                      #include <QtWidgets/QWidget>
                                      #include <ActiveQt/QAxBindable>
                                      #include <QtWidgets/QLayout>
                                      #include <QtWidgets/QApplication>
                                      #include <QtWidgets/QLCDNumber>
                                      #include <QTimer>
                                      #include <QApplication>
                                      #include <QDesktopWidget>
                                      #include <QMessageBox>
                                      #include <QPushButton>
                                      
                                      #include "ui_osgactiveglqt.h"
                                      
                                      #include "ActiveQTOSGWidget.h"
                                      
                                      class osgActiveGLQT : public QWidget,public QAxBindable
                                      {
                                      	Q_OBJECT
                                      public:
                                      	osgActiveGLQT(QWidget *parent = 0);
                                      private:
                                      	Ui::osgActiveGLQTClass ui;
                                      };
                                      
                                      #endif // OSGACTIVEGLQT_H
                                      1 Reply Last reply
                                      0
                                      • hskoglundH Offline
                                        hskoglundH Offline
                                        hskoglund
                                        wrote on last edited by
                                        #19

                                        Hmm it works for me, I tried with the hierarchyax sample and when I set WIDTH and HEIGHT in test.html:

                                        ..
                                        <p>
                                        This widget can have many children!
                                        </p>
                                        <object ID="ParentWidget" WIDTH = "900" HEIGHT = "600" CLASSID="CLSID:d574a747-8016-46db-a07c-b2b4854ee75c"
                                        [Object not available! Did you forget to build and register the server?]
                                        </object><br />
                                        ...
                                        

                                        the ActiveQt window is set to 900x600:
                                        Screenshot 2020-06-04 at 11.43.31.png

                                        M 1 Reply Last reply
                                        0
                                        • hskoglundH hskoglund

                                          Hmm it works for me, I tried with the hierarchyax sample and when I set WIDTH and HEIGHT in test.html:

                                          ..
                                          <p>
                                          This widget can have many children!
                                          </p>
                                          <object ID="ParentWidget" WIDTH = "900" HEIGHT = "600" CLASSID="CLSID:d574a747-8016-46db-a07c-b2b4854ee75c"
                                          [Object not available! Did you forget to build and register the server?]
                                          </object><br />
                                          ...
                                          

                                          the ActiveQt window is set to 900x600:
                                          Screenshot 2020-06-04 at 11.43.31.png

                                          M Offline
                                          M Offline
                                          mirro
                                          wrote on last edited by mirro
                                          #20

                                          @hskoglund
                                          oh~~ How to get the widget window from HWND in Qt5?

                                          The following QT4 code

                                          QWidget *myWidget;
                                          HWND hwnd;
                                          myWidget=QWidget::find(hwnd);
                                          
                                          1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved