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. [SOLVED] QMenuBar
Forum Updated to NodeBB v4.3 + New Features

[SOLVED] QMenuBar

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 2.5k 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.
  • M Offline
    M Offline
    mrstarware
    wrote on last edited by
    #1

    Hi, I'm trying to figure out why my QMenuBar doesn't work.

    @ WidgetVisible = ui->menuBar->addAction("Add Labels Screen");
    connect(WidgetVisible, SIGNAL(triggered()), this, SLOT(WidgetOn()));@

    then when I click on "Add Labels Screen" it doesn't do anything??

    Thank you for your help,

    mrstarware

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mlong
      wrote on last edited by
      #2

      That snippet of code seems reasonable. Do you get any error message? What does the WidgetOn() slot code look like?

      Software Engineer
      My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        Blizzard
        wrote on last edited by
        #3

        Does your console output a message like "no such slot" ?

        I agree with mlong, please show your slot code.

        Software Engineer | Aerospace & Defence

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mrstarware
          wrote on last edited by
          #4

          Ok I just found the application output. I didn't know it existed. x.x
          Anyway, it says "No such slot MainWindow::WidgetOn()" What would be causing this? the connection is made in MainWindow's constructor?

          1 Reply Last reply
          0
          • B Offline
            B Offline
            Blizzard
            wrote on last edited by
            #5

            in your mainwindow.h file you should have:
            @
            public slots:
            void WidgetOn();
            @

            And in your mainwindow.cpp your slot should look like:
            @
            void MainWindow::WidgetOn() {
            // code...
            }
            @

            Software Engineer | Aerospace & Defence

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

              Also, you want to make sure that your mainwindow.h file contains the Q_OBJECT macro, as well.

              Software Engineer
              My views and opinions do not necessarily reflect those of anyone -- living or dead, real or fictional -- in this universe or any other similar multiverse node. Void where prohibited. Your mileage may vary. Caveat emptor.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                mrstarware
                wrote on last edited by
                #7

                Oops. Messed up on the definition of "slot". It works now.

                Thanks much.

                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