Partage
  • Partager sur Facebook
  • Partager sur Twitter

menuBar() was not declared in this scope

    14 décembre 2017 à 15:20:08

    Hi

    im trying to create a menu in QT application and when i used menuBar() i got the following error:

    menuBar() was not declared in this scope !

    What i've understood from the Qt documentation is that menuBar() can be used when we have a MainWindow window means that we cannot use it under QDialog or QWidget !!!!!

    But me i want to use it under QDialog so how can i proceed is there any soloution for that ?

    thanks in advance  

    • Partager sur Facebook
    • Partager sur Twitter
      14 décembre 2017 à 21:11:37

      Hi,

      "XXX was not declared in this scope" is a message which informs you that the compiler doesn't know XXX.   In most cases, it appends when you forget to #include some header file.

      In this specific case, there are thtree main possibilities:

      • you didn't #include <QApplication> or
      • your class doesn't inherit from QApplication
      • you didn't used the full qualified name for the function( ex: void foo(){} in place of void MyClass::foo() {} )

      PS : Please note:

      We will be happy to help you, but, it's very more easy if you ... help us to help you, by giving us a minimal code which reporduce your problem.  For this, you can just copy and past your code using the < / > button.

      Openclassrooms -- as its name doesn't say it -- is ... a french forum.  Some of us have suffisant english knowledge to help you, but, most of us are just ... french speakers.  If you can write in french, you'll be welcome.  If not, you would have to wait some time for an answer in english, and you'll maybe have better time to find an english speakers forum ;)

      -
      Edité par koala01 14 décembre 2017 à 21:32:36

      • Partager sur Facebook
      • Partager sur Twitter
      Ce qui se conçoit bien s'énonce clairement. Et les mots pour le dire viennent aisément.Mon nouveau livre : Coder efficacement - Bonnes pratiques et erreurs  à éviter (en C++)Avant de faire ce que tu ne pourras défaire, penses à tout ce que tu ne pourras plus faire une fois que tu l'auras fait

      menuBar() was not declared in this scope

      × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
      × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
      • Editeur
      • Markdown