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. Get the window location of a custum QWidget

Get the window location of a custum QWidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 1.4k Views
  • 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    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() == 9

    I don't understand why mainView->pos() is in local space. Is it possible tu have the global position ?

    Best regards,
    Robin

    1 Reply Last reply
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by
      #2

      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,y

      Can I ask why you need this?

      1 Reply Last reply
      2
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by A Former User
        #3

        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 ^^

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • ? Offline
            ? Offline
            A Former User
            wrote on last edited by
            #5

            Is it possible to render a widget into a FBO ?
            I think Qt make his render on CPU.

            mrjjM 1 Reply Last reply
            0
            • ? A Former User

              Is it possible to render a widget into a FBO ?
              I think Qt make his render on CPU.

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @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

              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