Results 1 to 8 of 8

Thread: is qt self contained?

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default is qt self contained?

    When I went searching for a GUI framework what I had in mind was a designer like the qt designer that would allow me to design my GUI and then generate the code needed for the GUI so I could then add my own sub processes based on what buttons are clicked.

    It seems to me that qt doesn't generate any C++ code which can be edited. Am I wrong?

    In a nutshell, I want to create a network program using winsock2. Is it possible to make the GUI in designer and get it to work with my networking code?

  2. #2
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    21
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: is qt self contained?

    You don't edit the generated code directly - as this would be a mess if you change the widget an and re-generate the code.

    you have however several possibilities to use the widget in your application:
    http://doc.trolltech.com/4.3/designe...component.html

    usually you connect a few signals from the widget to your slots.

    niko

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: is qt self contained?

    Why don't you use Qt for networking as well? It would behave better than using a blocking socket with an event driven gui.

  4. #4
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: is qt self contained?

    Quote Originally Posted by Dumbledore View Post
    In a nutshell, I want to create a network program using winsock2. Is it possible to make the GUI in designer and get it to work with my networking code?
    Qt Designer generates a UI file, which is an XML representation of the layout. This UI file needs to be used within a Qt application, however. During the build, the UI file will be translated into C++, to link into your program. Typically you write a Qt widget class that instantiated that UI form. You can also load the UI form at runtime using the designer library, but this doesn't seem to be common, as it involves a bit of overhead and checking.

    But in all cases you need a C++ Qt application. All the Designer does is create widgets and lay them out. Any actual behavior needs to be written by you in C++ (or Python or Java).

    p.s. I second Wysota's suggestion to use Qt's networking. It gives you a nicer higher-level API for networking, and it's crossplatform to boot.

  5. #5
    Join Date
    Oct 2007
    Posts
    38
    Thanks
    1

    Default Re: is qt self contained?

    Any actual behavior needs to be written by you in C++
    How though? I need a tutorial on how to use designer to design the GUI and program it separately. In C#, for instance, it's intuitive enough to figure out how to code what each object in the UI does.

    Say for instance I create a button (in QT designer)

    Now I should have an object of type Button.

    So I should be able to find a method called "buttonPressed()" and describe what I want that button to do when it's pushed, no?

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: is qt self contained?

    Quote Originally Posted by Dumbledore View Post
    I need a tutorial on how to use designer to design the GUI and program it separately.
    Niko already gave you a link to it.

    http://doc.trolltech.com/4.3/designe...component.html
    http://doc.trolltech.com/4.3/designe...component.html
    http://doc.trolltech.com/4.3/tutorial.html

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: is qt self contained?

    If you open Qt docs, there is a link to a tutorial that explains all the basic steps, including the way to react to a button click.

  8. #8
    Join Date
    Mar 2006
    Location
    Mountain View, California
    Posts
    489
    Thanks
    3
    Thanked 74 Times in 54 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: is qt self contained?

    Quote Originally Posted by Dumbledore View Post
    So I should be able to find a method called "buttonPressed()" and describe what I want that button to do when it's pushed, no?
    No, but you will have a signal called "clicked()" that you can connect to. When the button is pressed, it will emit the clicked() signal, which will call the method (slot) you connected it to. You need to write that method though.

Similar Threads

  1. Replies: 2
    Last Post: 17th May 2006, 21:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.