Results 1 to 15 of 15

Thread: qt with glut on windows 10

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2019
    Posts
    8

    Default Re: qt with glut on windows 10

    Main.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3. #include <GL/glut.h>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. glutInit(&argc,argv);
    8. QApplication a(argc, argv);
    9. MainWindow w;
    10. w.show();
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    also when i place the line debugger on the gluinit
    it seems it something like a segmentation fault my guess cause glut isnt configured correctly, it runs for 2-3 secs then it crashes
    segfault.jpg

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qt with glut on windows 10

    Don't really have an idea on the crash, but you should not be using QGLWidget if you are on Qt5.

    Use QOpenGLWidget instead.

    Cheers,
    _

  3. #3
    Join Date
    Aug 2019
    Posts
    8

    Default Re: qt with glut on windows 10

    Yea i've heard of this however the only youtube video tutorial i've found the seemed complete and i could understand was using qglwidget. I don't think qglwidget is the problem because it was working before i added the glut.

  4. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qt with glut on windows 10

    Where is your GLWidget being constructed? Did you add it in Qt Designer (and so it is being constructed via setupUi())?

    You probably need to at least set the viewport size in the resizeGL() method:

    Qt Code:
    1. void GLWidget::resizeGL( int w, int h )
    2. {
    3. glViewport( 0, 0, (GLint)w, (GLint)h );
    4. }
    To copy to clipboard, switch view to plain text mode 

    You could simply your test case further by eliminating the MainWindow:

    Qt Code:
    1. #include "glwidget.h"
    2. #include <QApplication>
    3. #include <GL/glut.h>
    4.  
    5. int main(int argc, char *argv[])
    6. {
    7. glutInit(&argc,argv);
    8. QApplication a(argc, argv);
    9. GLWidget w;
    10. w.show();
    11. return a.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 

    This makes the GLWidget your top-level application widget and eliminates MainWindow as the cause of any errors.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  5. #5
    Join Date
    Aug 2019
    Posts
    8

    Default Re: qt with glut on windows 10

    Ok i am trying that debuggin technique and I get "call to constructor of 'GLWidget is ambigous call to overloaded function could be GL::GLWidget(QWidget*)' or GL::GLWidget(void) while trying to match argument list '0' i also include the glwidgets designer view


    glwidgetanonymous.jpgqtdesign.jpg

  6. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qt with glut on windows 10

    You probably need to change the signature for the GLWidget constructor to add a default value for the "parent" argument:

    Qt Code:
    1. // glwidget.h
    2.  
    3. class GLWidget : public QGLWidget
    4. {
    5. Q_OBJECT
    6.  
    7. public:
    8. GLWidget( QWidget * parent = 0 ); // default value for parent
    9.  
    10. //...
    11. }
    To copy to clipboard, switch view to plain text mode 
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  7. #7
    Join Date
    Aug 2019
    Posts
    8

    Default Re: qt with glut on windows 10

    it did have that in glwidget.h with the word explicit at the beginning but no Q_OBJECT, i tried adding Q_OBJECT but then i get build time errors so i removed it again

  8. #8
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: qt with glut on windows 10

    Quote Originally Posted by gtx View Post
    Yea i've heard of this however the only youtube video tutorial i've found the seemed complete and i could understand was using qglwidget. I don't think qglwidget is the problem because it was working before i added the glut.
    I also don't think it is the cause of the problem but why use obsolete technology when the replacement is virtually identical in API?

    Quote Originally Posted by gtx View Post
    it did have that in glwidget.h with the word explicit at the beginning but no Q_OBJECT, i tried adding Q_OBJECT but then i get build time errors so i removed it again
    It should't matter unless you define your own slots, signals or properties.

    However, if you get build errors when adding the Q_OBJECT marker the usual fix is to re-run qmake.

    Cheers,
    _

  9. #9
    Join Date
    Aug 2019
    Posts
    8

    Default Re: qt with glut on windows 10

    ok ive reran qmake and the q_object build errors went away but the program is still crashing after a few secs in runtime urgh.

  10. #10
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qt with glut on windows 10

    the program is still crashing after a few secs in runtime
    Then you really need to learn how to use the debugger and run your program in debug mode. When the program crashes, you look at the call stack and that will tell you the complete sequence of calls made by your program from the beginning up to the point where the crash occurs.

    Just keep in mind that -where- the crash occurs might not be the actual cause that leads to the crash. For example, a memory error earlier in the program may not actually cause a problem until the code that tries to use the corrupted memory gets executed. You need to look at not only where the crash happens, but what the program is trying to do when it crashes.

    Once you have established where the crash happens, if you don't understand why then report back and maybe someone here can provide some help. Just don't post screen shots of the call stack, copy and paste the text instead.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  11. #11
    Join Date
    Aug 2019
    Posts
    8

    Default Re: qt with glut on windows 10

    I have added that line to glwidget.h but i'm still getting call to constructor GLWidget w; is ambigous

    main.cpp

    Qt Code:
    1. GLWidget w;
    2. w.show();
    To copy to clipboard, switch view to plain text mode 
    on the GLWidget w; line

  12. #12
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: qt with glut on windows 10

    Your GLWidget class shows two constructors in its header:

    Qt Code:
    1. GLWidget();
    2.  
    3. // and
    4.  
    5. explicit GLWidget( QWidget * parent = 0 );
    To copy to clipboard, switch view to plain text mode 

    These two are indistinguishable to the compiler when used as you are doing ("GLWidget w;"). Get rid of the first constructor (GLWidget()) and the warning will go away.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Linking glut to Qt
    By Mashkur in forum Qt Tools
    Replies: 1
    Last Post: 14th October 2012, 18:18
  2. How to link glut.h?
    By connect_qt in forum Newbie
    Replies: 3
    Last Post: 15th November 2011, 22:14
  3. Qi with glut
    By hudi in forum Qt Programming
    Replies: 7
    Last Post: 14th April 2010, 11:41
  4. using GLUT along with qtcreator/mingw in windows
    By stephanepoirier in forum Qt Programming
    Replies: 1
    Last Post: 3rd March 2009, 05:26

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.