Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Problem in compiling, QGraphicsScene::setActiveWindow() not accepting a QGLWidget subclass

    Game Development
    2
    5
    2569
    Loading More Posts
    • 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.
    • K
      Karunesh last edited by

      I had a QGLWidget subclass as the graphics class, which I now want to be used as a single window in a QGraphicsScene in order to accomodate the menu.

      It looks like this:
      GLWindow class
      @
      #ifndef GLWINDOW_H
      #define GLWINDOW_H

      #include <things>
      class GLWindow : public QGLWidget , public QGraphicsProxyWidget // tried QGraphicsWidget too.
      {
      Q_OBJECT
      public:
      GLWindow(QWidget *parent = 0);
      ~GLWindow();

      void resizeGL(int width, int height);
      void initializeGL();
      void paintGL();
      

      // Other functions, signals/slots etc.
      // .............................
      };
      #endif // GLWINDOW_H@

      main.cpp
      @
      #include <QtGui/QApplication>
      #include "glwindow.h"
      #include <QDebug>
      #include <QGraphicsScene>
      #include <QGraphicsView>
      #include <QGraphicsProxyWidget>

      int main(int argc, char *argv[])
      {
      QApplication a(argc, argv);
      GLWindow w;

      // ...............THIS WORKS.........................
      //#ifndef Q_WS_MAEMO_5
      // w.showMaximized();
      //#else
      // w.showFullScreen();
      //#endif

      //...............But This Does not...................
      QGraphicsScene scene;
      scene.setActiveWindow(w);
      //scene.setActiveWindow((dynamic_cast<QGraphicsProxyWidget*>)(w)); // ... did not work
      QGraphicsView view(&scene);
      view.showMaximized();

      return a.exec&#40;&#41;;
      

      }@

      I understand that the "setActiveWindow()":http://doc.qt.nokia.com/4.8-snapshot/qgraphicsscene.html#setActiveWindow method requires a QGraphicsWidget object, but I still am not able to compile after subclassing QGraphiscWidget (and QGraphicsProxyWidget). Trying to dynamic_cast my QGLWidget subclass did not work either. The error is something like:

      • ..\main.cpp:22: error: no matching function for call to 'QGraphicsScene::setActiveWindow(GLWindow&)'

      I also tried modifying the constructor declaration for GLWindow class as:
      @GLWindow(QWidget *parent = 0, QGraphicsProxyWidget *parent = 0);@

      but still no progress. (I dont think I should be doing this, but there was no harm in trying!)

      Appreciate any help from someone who already has done this. Any comments are welcome.

      Thanks and regards
      Karunesh

      1 Reply Last reply Reply Quote 0
      • K
        koahnig last edited by

        setActiveWindow is requiring a pointer and not a reference see the link you have provided.

        try this:
        @
        QGraphicsScene scene;
        scene.setActiveWindow(&w);
        //scene.setActiveWindow((dynamic_cast<QGraphicsProxyWidget*>)(w)); // ... did not work
        @

        Vote the answer(s) that helped you to solve your issue(s)

        1 Reply Last reply Reply Quote 0
        • K
          Karunesh last edited by

          Hi koahnig

          I tried using that too, but got the following error:

          • ..\main.cpp:22: error: no matching function for call to 'QGraphicsScene::setActiveWindow(GLWindow*)'

          Thanks and regards
          Karunesh

          1 Reply Last reply Reply Quote 0
          • K
            koahnig last edited by

            I am not sure, but it may have to do with the mutiple inheritance. But this is byeond my expertize.

            However, have you tried to with a single inheritance (of QGraphicsProxyWidget) too?

            Vote the answer(s) that helped you to solve your issue(s)

            1 Reply Last reply Reply Quote 0
            • K
              Karunesh last edited by

              Hi koahnig

              I tried that, but it results a lot of other errors, basically pertaining to undefined OpenGL/QtGL things. Inheriting QGLWidget is kind of necessary.
              Thanks for helping anyways.

              Thanks and regards
              Karunesh

              1 Reply Last reply Reply Quote 0
              • First post
                Last post