Why can't ie11 load the DLL generated by the qt-5.6/activeqt-hierarchy-example?
-
@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>
-
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.
-
@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>
-
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. -
@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>
-
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
-
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
-
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: