Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Menu without action
Forum Updated to NodeBB v4.3 + New Features

Menu without action

Scheduled Pinned Locked Moved Solved General and Desktop
16 Posts 5 Posters 2.7k Views 4 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.
  • M Offline
    M Offline
    mpergand
    wrote on last edited by mpergand
    #7

    It's very unusual for a menu to trigger an action directly, it's more like a button behaviour.
    If you want some buttons to trigger actions use a Toolbar, that's what it is made for.

    Cordialement :)

    1 Reply Last reply
    2
    • jsulmJ jsulm

      @yogis40 said in Menu without action:

      Unfortunately it's not working

      What exactly does not work? The connect? ...?

      Y Offline
      Y Offline
      yogis40
      wrote on last edited by
      #8

      @jsulm
      Hi, the compilation goes fine but when I click on the Clear menu as shown in the snapshot, the QtextEdit::clear method is not called or not working.
      B/R
      yogis40

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #9

        Hi,

        As written in the triggered signal documentation:

        • This signal is emitted when an action in this menu is triggered.

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        Y 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          As written in the triggered signal documentation:

          • This signal is emitted when an action in this menu is triggered.
          Y Offline
          Y Offline
          yogis40
          wrote on last edited by
          #10

          @SGaist :
          Hi,
          Thanks for your reply. I've looked into the documentation and not found a 'click' action in QtMenu.
          Thanks by advance

          Y 1 Reply Last reply
          0
          • Y yogis40

            @SGaist :
            Hi,
            Thanks for your reply. I've looked into the documentation and not found a 'click' action in QtMenu.
            Thanks by advance

            Y Offline
            Y Offline
            yogis40
            wrote on last edited by
            #11

            @yogis40
            Sorry, i’ve Forgotten to ask my question.
            How do we catch when the user is clicking on ‘Clear’ menu ? Is it possible to specify the ‘Clear’ in the QMenu::triggered(&Clear)
            ?
            Thanks for your help and sorry to ask but I’m a newbie and struggle with Qt.

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by SGaist
              #12

              It's not exactly a Qt problem. It's what you are trying to do. You're going against the UI guidelines of all desktop environments and against the normal usage of a menu.

              The content of the menu bar is menus. Clicking on a menu should not trigger anythings else that showing its content.

              Your clear action should be in for example an edit menu. You can put accelerator on it and even a keyboard shortcut.

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              3
              • mrjjM Offline
                mrjjM Offline
                mrjj
                Lifetime Qt Champion
                wrote on last edited by mrjj
                #13

                Hi
                Just had a test.
                connect(ui->menuClear,&QMenu::triggered, ui->textEdit, &QTextEdit::clear);
                does not work as a top menu (with no sub items) added in Designer does not call triggered.
                (it has no QAction to be triggered)
                That is why its not working - as its expected to have sub items.

                That said, its possible from code, using an QAction instead.

                QAction *a = new QAction("Clear", this);
                ui->menuBar->addAction(a);
                connect(a, &QAction::triggered, ui->textEdit, &QTextEdit::clear);
                

                That works however as SGist says, its not really a normal way for menus to work seen
                from a users perspective. a clear command would normally be in Edit sub menu.

                1 Reply Last reply
                1
                • Y Offline
                  Y Offline
                  yogis40
                  wrote on last edited by
                  #14

                  Hello,
                  Thanks for your help and your answers.

                  Regarding the UI guidelines, I’m interested to found it. As mentioned previuously, I’m newbie in Qt and the last time I’ve programmed a UI it was in Visual Basic in 2004. Then, 15-years ago...

                  Thanks.

                  mrjjM SGaistS 2 Replies Last reply
                  0
                  • Y yogis40

                    Hello,
                    Thanks for your help and your answers.

                    Regarding the UI guidelines, I’m interested to found it. As mentioned previuously, I’m newbie in Qt and the last time I’ve programmed a UI it was in Visual Basic in 2004. Then, 15-years ago...

                    Thanks.

                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #15

                    @yogis40
                    Hi
                    Welcome back to GUI programming then :)
                    Such single click activation commands are often put in the QToolbar
                    (Lives just under the menu)

                    alt text

                    1 Reply Last reply
                    2
                    • Y yogis40

                      Hello,
                      Thanks for your help and your answers.

                      Regarding the UI guidelines, I’m interested to found it. As mentioned previuously, I’m newbie in Qt and the last time I’ve programmed a UI it was in Visual Basic in 2004. Then, 15-years ago...

                      Thanks.

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #16

                      @yogis40 said in Menu without action:

                      Regarding the UI guidelines, I’m interested to found it. As mentioned previuously, I’m newbie in Qt and the last time I’ve programmed a UI it was in Visual Basic in 2004. Then, 15-years ago...

                      There's per platform:

                      • KDE's human interface guidelines
                      • Apple's human interface guildines for macOS
                      • Apple's human interface guildines for iOS
                      • Apple's human interface guildines for tvOS
                      • Windows desktop guideline

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2

                      • Login

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