Page 2 of 2 FirstFirst 12
Results 21 to 29 of 29

Thread: error: expected unqualified-id before numeric constant

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: expected unqualified-id before numeric constant

    And are you positive that the error is from that line, where you create the QKeyEvent?

    And what about this?
    Qt Code:
    1. QKeyEvent *e=new QKeyEvent(QEvent::KeyPress,65,Qt::NoModifier,QStri ng("> "));
    To copy to clipboard, switch view to plain text mode 

    There is still a space in the middle of QString.
    Jpn also asked this, and now you have the same error? How is this a copy-paste error?

    Regards

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: expected unqualified-id before numeric constant

    I still cannot spot the error.
    Does it compile if you remove that line?

    Apart from the problem you have, this is not correct:
    Qt Code:
    1. QKeyEvent *e=new QKeyEvent(QEvent::KeyPress,65,Qt::NoModifier,QStri ng("> "));
    2. keyPressEvent(e);
    To copy to clipboard, switch view to plain text mode 

    keyPressEvent is not meant to be called like that.
    Use qApp->postEvent instead.

    Regards

  3. #3
    Join Date
    Feb 2007
    Posts
    32
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: expected unqualified-id before numeric constant

    Hi Marcel,
    Could you get some clue? I have traced that due to QEvent::KeyPress, the error is coming, Compiler is unable to recognize the the keyword.

  4. #4
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: error: expected unqualified-id before numeric constant

    Could you post the include section from that file?
    All the includes.

    Regards

  5. #5
    Join Date
    Sep 2008
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: error: expected unqualified-id before numeric constant

    Hi,

    I'm using Qt4.1, and I had the same problem and I have resolved it with an include and a replacement :
    #include <QKeyEvent> //that's very important
    (QEvent::Type)6 instead of QEvent::KeyPress

    example :
    KeyEvent* kevent = new QKeyEvent((QEvent::Type)6,buffer[0],(Qt::KeyboardModifiers)Qt::NoModifier,buffer,fals e,1);

    I hope it will help someone.

  6. #6
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: error: expected unqualified-id before numeric constant

    You sure don't have to use such ugly C-style casts when you have the necessary include directive in place.

    Qt Code:
    1. #include <QKeyEvent>
    2. ...
    3. QKeyEvent* kevent = new QKeyEvent(QEvent::KeyPress,buffer[0],Qt::NoModifier,buffer,false,1);
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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
  •  
Qt is a trademark of The Qt Company.