Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Learning
  3. Qt in Education
  4. Absolute Beginner
Forum Updated to NodeBB v4.3 + New Features

Absolute Beginner

Scheduled Pinned Locked Moved Qt in Education
9 Posts 2 Posters 4.0k Views 2 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.
  • C Offline
    C Offline
    ChrisOfBristol
    wrote on last edited by
    #1

    I have tried out a few GUI Designers and am most impressed with Qt, so I am using it to create a very simple GUI, linking the .ui form into the Python program.
    I have succeeded in making buttons and radiobuttons work*, but can't work out how to write the actions for the rest of my GUI - a scrollbox and the menubar File/Open,Quit and Help/Help,About.

    There are examples under the Documentation heading but I think they are all written in C and I wish to use Python. I have trawled through loads of helpful websites, but most people are writing for when pyuic has been used to create a Python script from the ui file. I've had a look in that file for ideas, but don't know which statements in it would be needed and what else to add.

    Is there a basic tutorial which would introduce me to this?

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

      Hi and welcome to devnet,

      You might be interested by this page

      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
      0
      • C Offline
        C Offline
        ChrisOfBristol
        wrote on last edited by tekojo
        #3

        Thanks SGaist, I think I have looked at all of those now. I have given up on trying to find much information on importing the ui form. The reason I wanted to use that method was because it avoided having to fill my program with the gui statements which would be needed if I used pyuic4 to convert it into Python statements. However I have discovered that I can import the Python file into my program which overcomes the problem, so I have switched to using that method and am making progress.

        I have worked out how to use signals and slots to link the widgets to actions which create code, which is more or less all I need to know:

        bq. Sender_____Signal______Receiver___ Slot
        actionQuit___triggered()__Form_____close()
        

        All I'm confused about, is what to do when there is no suitable receiver+action, in this example I want /Help/About to show a message box, but there is no messagebox widget, so I will have to do that in my Python program.

        bq. Sender______Signal_______ Receiver___Slot
        actionAbout___triggered()___ <receiver>__<slot>  
        

        pyuic4 has created an object (if that's the right term):

        self.menuHelp.addAction(self.actionAbout)
        

        All I now need to do is write an action in my Python program like:

         def actionAbout(self):
                       print 'About has activated'
        

        This doesn't work, but I think it's something like right...

        I'm sure I'm nearly there, as I am capable in other programming languages, it's the starting off that's hard!

        1 Reply Last reply
        0
        • C Offline
          C Offline
          ChrisOfBristol
          wrote on last edited by tekojo
          #4

          it's taken me all day to work it out, but all I needed was to change the first line 1) to:

              self.actionAbout.triggered.connect(self.actionAbout)
          

          I'm away now...

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

            Any other problem ?

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

            C 1 Reply Last reply
            0
            • SGaistS SGaist

              Any other problem ?

              C Offline
              C Offline
              ChrisOfBristol
              wrote on last edited by
              #6

              @SGaist Yes! I have now created and published a simple app. I will be making a few improvements to it.

              I have been wondering what the pros and cons are for choosing between importing uic to load the GUI.ui or using pyuic4 to convert the GUI.ui into a .py file.
              The first method is simpler for testing, but the second creates a .pyc file after the first run, so I wonder if that loads the app quicker. It's difficult to do a comparison as other factors are involved. Speeding up the loading would be helpful, are there are other advantages?

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

                Unless your application should be able to create dynamically custom user interface based on ui files, just use pyuic4

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

                C 1 Reply Last reply
                1
                • SGaistS SGaist

                  Unless your application should be able to create dynamically custom user interface based on ui files, just use pyuic4

                  C Offline
                  C Offline
                  ChrisOfBristol
                  wrote on last edited by
                  #8

                  @SGaist Is there any disadvantage to sticking with the first method though?

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

                    I'd say you have to ensure that you also deploy the ui file properly so that it can be found by your application

                    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
                    0

                    • Login

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