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. Where is PeekMessage Func in Qt SDK?
Forum Updated to NodeBB v4.3 + New Features

Where is PeekMessage Func in Qt SDK?

Scheduled Pinned Locked Moved Game Development
9 Posts 6 Posters 6.1k Views 1 Watching
  • 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.
  • A Offline
    A Offline
    ahaaac
    wrote on last edited by
    #1

    @
    if (PeekMessage(&Message,NULL,0,0,PM_REMOVE)) {
    if (Message.message==WM_QUIT)
    break;
    TranslateMessage(&Message);
    DispatchMessage(&Message);
    }
    else {
    Render()
    }
    @

    I want this code in Qt

    but i can not find PeekMessage in Qt SDK

    someone help me please

    [EDIT: code formatting, please wrap in @-tags, Volker]

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tobias.hunger
      wrote on last edited by
      #2

      Can you please provide some context to this code? What is it supposed to do and where is it supposed to run?

      1 Reply Last reply
      0
      • L Offline
        L Offline
        lgeyer
        wrote on last edited by
        #3

        This is not how Qt works. See "The Event System":http://developer.qt.nokia.com/doc/qt-4.8/eventsandfilters.html and "QApplication":http://developer.qt.nokia.com/doc/qt-4.8/qapplication.html, especially QCoreApplication::processEvents() and QCoreApplication::exec().

        1 Reply Last reply
        0
        • A Offline
          A Offline
          ahaaac
          wrote on last edited by
          #4

          I want rendering in (windows, linux, mac) use OpenGL

          @if( no event ) // if there is no event in loop
          {
          RenderScene(); // I want rendering my scene
          }
          else // if events in loop
          {
          processEvent(); // get them!
          }@

          1 Reply Last reply
          0
          • sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #5

            Use QGLWidget, then. No need to go into the event loop itself (probably. It does, of course, depend on what you want to achieve).

            (Z(:^

            1 Reply Last reply
            0
            • M Offline
              M Offline
              matti-
              wrote on last edited by
              #6

              Inherit from QGLWidget and use a QTimer to schedule your renders.

              Author of <a href="http://mmark.777-team.org/">MMark13</a>

              1 Reply Last reply
              0
              • A Offline
                A Offline
                ahaaac
                wrote on last edited by
                #7

                thank you all!

                QGLWidget and QTimer is solve my problem!

                but in this case, my program is crash!

                @class Display : public QGLWidget
                {
                Q_OBJECT
                public:
                Display(QWidget *parent = 0);
                ~Display();

                public:
                void resizeGL(int w, int h);
                void initializeGL();
                void paintGL();

                signals:

                public slots:
                };

                void Display::resizeGL(int w, int h)
                {
                }

                void Display::initializeGL()
                {
                }

                void Display::paintGL()
                {
                glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                glClearColor(0.0, 0.0, 0.0, 1.0);

                glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
                
                glBegin(GL_QUADS);
                
                glVertex3f(-0.5, 0.0, -0.5);
                glVertex3f( 0.5, 0.0, -0.5);
                glVertex3f( 0.5, 0.0,  0.5);
                glVertex3f(-0.5, 0.0,  0.5);
                
                glEnd();
                
                QTimer::singleShot(0, this, SLOT(updateGL()));
                

                }@

                .....hmm Why? Why this code is crash?

                it is just draw one polygon. :(

                1 Reply Last reply
                0
                • G Offline
                  G Offline
                  giesbert
                  wrote on last edited by
                  #8

                  Hi,

                  why do you trigger a repaint in the repaint? That does not make sense.
                  And where exactly does it crash? You needn't trigger the repaint, it is sufficient to it if something changes.

                  By the way, a side not to your first post: you said you want to run this on multiple üöatforms. The code (Peek/Translate/DispatchMessage) is win32 API ;-)

                  Nokia Certified Qt Specialist.
                  Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    ahaaac
                    wrote on last edited by
                    #9

                    why do you trigger a repaint in the repaint? >>

                    without QTimer::singleShot(0, this, SLOT(updateGL()))
                    paintGL() Func is not repaint in this case

                    @void Display::paintGL()
                    {
                    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
                    glClearColor(0.0, 0.0, 0.0, 1.0);

                    glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
                    
                    
                    static int Angle = 0;
                    
                    ++Angle;
                    
                    glPushMatrix();
                    glRotatef(Angle, 0.0f, 0.0f, 1.0f);
                    glBegin(GL_QUADS);
                    
                    glVertex3f(-0.5, 0.0, -0.5);
                    glVertex3f( 0.5, 0.0, -0.5);
                    glVertex3f( 0.5, 0.0,  0.5);
                    glVertex3f(-0.5, 0.0,  0.5);
                    
                    glEnd();
                    glPopMatrix();
                    

                    }@

                    where exactly does it crash? >>

                    it is not crash all the time
                    and it's crash point is not same all the time
                    and this crash is fixed QTimer::singleShot Func's msec value change (0 -> 10)

                    By the way, a side not to your first post>>

                    I'm sorry. and thank you for your Advice Gerolf :)

                    and thank you all. dude!

                    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