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. QT widgets tutorial

QT widgets tutorial

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 706 Views
  • 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.
  • P Offline
    P Offline
    peredur
    wrote on last edited by
    #1

    Is it me, or does the first page of the tutorial not make any sense? I'm trying to follow the instructions at: https://doc.qt.io/qt-5/qtwidgets-tutorials-notepad-example.html

    I'm new to Qt and trying to work out how to use it for applications and how to use the IDE.

    Having followed the instructions in Designing a UI --> Using Qt Designer, the section Notepad Header File states that the wizard should have created a header file with a whole bunch of information in it, but mine has nothing in it except for a minimal class declaration with just the Q_OBJECT macro, a constructor declaration, a destructor declaration and a private Ui::Notepad member.

    Similarly, the source file has about 15 lines in it as opposed to the very large file displayed in the tutorial.

    It must be me, but can anyone tell me what I'm missing, please?

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

      Hi and welcome to the forums.
      its just in an odd order. they explain how the UI files work first
      but its actually first in section
      Adding User Interaction
      where they talk about using Goto Slot to have it generate slot for the buttons and menus.
      So just keep reading and it should be fine.

      P 1 Reply Last reply
      4
      • mrjjM mrjj

        Hi and welcome to the forums.
        its just in an odd order. they explain how the UI files work first
        but its actually first in section
        Adding User Interaction
        where they talk about using Goto Slot to have it generate slot for the buttons and menus.
        So just keep reading and it should be fine.

        P Offline
        P Offline
        peredur
        wrote on last edited by
        #3

        @mrjj Ah yes! Thanks. And apologies for my lack of perseverance.

        mrjjM 1 Reply Last reply
        3
        • P peredur

          @mrjj Ah yes! Thanks. And apologies for my lack of perseverance.

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

          @peredur
          Np :) Actually it has been asked before as the tutorial reads funny as they show
          the .h file with all the added slots but just after running the wizard, that's not what you have at that point which naturally is confusing.

          P 1 Reply Last reply
          0
          • mrjjM mrjj

            @peredur
            Np :) Actually it has been asked before as the tutorial reads funny as they show
            the .h file with all the added slots but just after running the wizard, that's not what you have at that point which naturally is confusing.

            P Offline
            P Offline
            peredur
            wrote on last edited by
            #5

            @mrjj And I have to confess that I still don't get it. The Adding User Interaction section starts of by saying: "Click on "Type Here", and add the options New, Open, Save, Save as, Print and Exit." But this doesn't make any sense either since the illustrations show top level menu items of "Fill" and "Edit". So shouldn't those be added first?

            Then the tutorial moves on to say that we'll fill in the newDocument() method. But where has that come from?

            I know that asking this is very risky, but am I particularly stupid? I really can't follow this tutorial at all.

            :(

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

              Hi
              Nope, the tut could have described in more details how and where to click.
              I recall that at some point, the Application template might have been more like in the tut
              and not as bare bone as its now. Maybe that is why there seems steps missing.

              And you are right, you have to fill out the Top level menus first, to add the submenus
              alt text

              After you type at "type here", an action is added to the action editor below the form
              alt text

              You can then RIGHT click the action,
              alt text
              and you find the Goto Slot there
              alt text
              where you select the signal to create the slot for.
              (the slot being your function to call when the menu (the action) is activated. (clicked)
              and then create the slot to be filled out
              alt text

              However, in the tut, the seems to have the slot typed in manually. ( or it was another wizard at some point)
              Adding a slot is just like adding a member function to the .h/cpp file but just listed under slots.

              private slots:
              void newDocument();

              and its then manually connect to the action
              connect(ui->actionNew, &QAction::triggered, this, &Notepad::newDocument);
              (this is like using Goto Slot but connected from code instead, which is recommended for real apps. )
              The connect line says
              connect the actionNew triggered signal to the newDocument slot.
              so its much the same as using Goto Slot menu but done from code.

              So I guess at some point the New Application Wizard would create such notepad like the sample
              in tut but now only creates a barebone MainWindow project. ( or i missed something obvious)
              So i think that is why it feels a bit off trying to follow.

              However, you can add some of the actions and slot and fill out as they say.
              (using Type Here and Goto Slot)

              1 Reply Last reply
              3

              • Login

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