New to GUI



  • This stuff is awesome. I have been coding C++ for years without any GUIs. Now that I found Qt everything makes so much more sense. Still, I need a little help.

    I want to take a number from the entry tool, and when I click a button. I want to print something to a text area as many times as the number in the entry tool designates.

    Please any help, I'm new!



  • Welcome to DevNet,

    I suggest to start from the "examples and tutorial":http://doc.qt.io/qt-5/qtexamplesandtutorials.html

    Try to create a "Qt Widget based":http://doc.qt.io/qtcreator/creator-writing-program.html application

    Then try Qml application.



  • I have been reading examples, following tutorials, and watching youtube. None of them have helped me with this specific problem. Could you at least direct me to something more specific?



  • As posted above try Widget first. You can use the form designer to put the following things on the form:

    line edit (input)
    button

    Then for showing the output you could use

    List widget

    For your first approach use code-behind. This means you put your logic to do things right in the connections for the thing that raised the signal.

    Example:

    For the button create clicked connection. In that connection (C++ code) you get whatever is entered in the line edit, then you have a loop that prints it out tot he list widget.

    Pretty much all of your code is in the one method that is called when clicked() happens.

    After you put the objects on the form (buttons, line edit, list) each will be usable in your code. Each gets an automatically generated name. You can change the names but for a simple test you can just leave them.

    For example the button becomes:

    pushButton

    When you are in the form editor you change to signals mode on the edit menu. Then you click on your pushButton in the form view, drag to the form. This will open a dialog where you can create a new function that will be called when the button is clicked.

    in that function you'd write your code to get what is in the line edit (using its object name) and loop and print it out to the list.



  • Thanks, I think. I mean it makes sense, but I still need to visualize it. Is it possible you could code me a test case that I could then compile?







  • OKAY! SysTech, your program runs like a dream. The only problem I am having now is with the Qt IDE. Your program compiles and runs, but I'm not able to view it inside the Qt IDE. In fact the button labeled layout isn't even active no matter what I do. So I can't see your work outside of a text editor.

    Any help or advice?



  • Found the problem, sorry everybody. Ha!



  • Hi CoreyWhite,
    I'm also new to Qt GUI just like you. Nice that you solved this little button problem. I just wanted to point out that if you're planning on creating some more advanced UI or hoping to extend QML apps with C++ code (since you're experienced in C++), be prepared for a lot and I mean a lot of frustration (especially if you're using recent versions of Qt like 5.3 or 5.4). Practically there's NULL learning resources around for a beginner.

    Good luck.



  • Thanks for the reply. Maybe we could try to help each other. My e-mail address it adventmagic@gmail.com , if you want to write me. I think this is actually pretty straighforward, when you compare it to other IDE's like Microsoft Visual C++. I'm actually just happy to have found this stuff. I've never buiult a GUI before.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.