Get the window location of a custum QWidget
-
Hi,
I just need to know how I can get the window location of a custum QWidget.
I have this own widget :class ColorPicker : public QWidget { Q_OBJECT public: QHBoxLayout* layout; ColorGradient* mainView; }; ColorPicker::ColorPicker(QWidget *parent) : QWidget(parent) { this->layout = new QHBoxLayout; setLayout(this->layout); this->mainView = new ColorGradient; this->layout->addWidget(this->mainView); } class ColorGradient : public QWidget { public: ColorGradient(QWidget *parent = 0);
I have for my widget ColorPicker* colorpicker->pos().y() == 130
and for colorpicker->mainView->pos().y() == 9I don't understand why mainView->pos() is in local space. Is it possible tu have the global position ?
Best regards,
Robin -
Hi
When a widget is a child of a other widget, its x,y are relative to parent.
You can use
http://doc.qt.io/qt-5.5/qwidget.html#mapToGlobal
To convert the child x,y to global x,yCan I ask why you need this?
-
Thanks A lots!
I need this to repaint a HUD into a texture. But I didn't need to update the entire HUD. So I use the function grab on interest widget and I repose them at the correcte location.
It could seen experimental. And it'is ^^
-
yes sounds slightly experimental :)
there is also
http://doc.qt.io/qt-5.5/qwidget.html#render
but seems u need the real widget in new pos. -
Is it possible to render a widget into a FBO ?
I think Qt make his render on CPU. -
@Robinsondesbois
Im not good with opengl but it think its possible
http://stackoverflow.com/questions/7178186/how-to-draw-qglframebufferobject-onto-the-painter-from-within-qgraphicsitempai