Compose pointer to property of object
-
hi
Im not sure what wrong with QList since its dynamic and
we cant have invalid pointers around ?
else use a map
http://doc.qt.io/qt-5/qmap.html
QMap<int,QWebView * > map;
QWebView *webGUI = new QWebView(this);
...
map[1] =webGUI ;
map[2] =nextwebGUI ;
...
QWebView *w=map[2]; // it will stay "2"They wont change position as 1,2 is a key
like map["onekey"] =webGUI ;
but we use int as no need for string.
so even if we remove map[1] then
map[2] is still there.So maybe it works better for you ?
-
So far, everything related to this threads question and the QMap as solution seems to work.
I stumbled over something else while relacing the QwebView from the Designer by my 'on-demand' created one:
I can not load an url, it crashes with sig11.I get the following connect error on bootup:
QMetaObject::connectSlotsByName: No matching signal for on_webGUI_loadFinished(bool)
which I dont understand and may be the cause.
I have connected:connect(webGUI, SIGNAL(loadFinished(bool)), this, SLOT(on_webGUI_loadFinished(bool)));
and in *.h as private slot:
void on_webGUI_loadFinished(bool arg1);
This worked before, with the QWebView from the Designer.
Any idea? Thanks. -
@McLion said:
no matching signal for on_webGUI_loadFinished(bool)
Hi
this warning comes as you name slot on_XXX
This will trigger Qt auto connect feature so when you use
a concrete connect you should rename it so it dont
start with on__
(right click it- refactor->rename)also please do
qDebug() << "loadfin:" << connect(webGUI, SIGNAL(loadFinixxxxto see if it returns true; ( as in , it can connect)
-
You're most probably dereferencing a null pointer. Signal 11 means SIGSEGV (segmentation error).
-
@jsulm
Yes - Thanks . Problem loacted, but not yet solved:void QTGUI_MainWindow::populateJavaScriptWindowObject() { QWebView * webGUI = qobject_cast<QWebView *>(sender()); webGUI->page()->mainFrame()->addToJavaScriptWindowObject("NativeBridge", this); }
The sender is the JS and not the QWebView and so I do not get the pointer to the QWebView that I need. Instead, the pointer is 0x0 and then - of course - the addToJ... crashes.
Any idea how I get the pointer to the QWebView from which the JS is sending?
Thanks -
What is JS?