Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Problem in compiling, QGraphicsScene::setActiveWindow() not accepting a QGLWidget subclass
QtWS25 Last Chance

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

Scheduled Pinned Locked Moved Game Development
5 Posts 2 Posters 2.8k 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.
  • K Offline
    K Offline
    Karunesh
    wrote on last edited by
    #1

    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
    0
    • K Offline
      K Offline
      koahnig
      wrote on last edited by
      #2

      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
      0
      • K Offline
        K Offline
        Karunesh
        wrote on last edited by
        #3

        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
        0
        • K Offline
          K Offline
          koahnig
          wrote on last edited by
          #4

          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
          0
          • K Offline
            K Offline
            Karunesh
            wrote on last edited by
            #5

            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
            0

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved