Results 1 to 5 of 5

Thread: Need help writing my first Qt app

  1. #1
    Join Date
    Dec 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Need help writing my first Qt app

    Hello people!

    First (of many) post on these forums... and I need a little bit of help. I have written a program in native c++ that works fine and now want to build a GUI application that does the same thing - that is given an input sequence of amino acids find the molecular weight and formula of the protein the sequence represents. Before I go any further I must tell you that I have no prior experience in GUI programming although I'm pretty well versed with C++.

    I have built the 'main screen' (widget?) for my app with the necessary lineEdits and labels and buttons using Qt Creator but I can't figure out where to put in my code that does the actual processing.

    Could you please point me in the right direction? Thanks!

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Need help writing my first Qt app

    Quote Originally Posted by netnut View Post
    native c++
    There is no such thing as "native" C++. You want to say C++ making use of only the standard libraries?

    I have built the 'main screen' (widget?) for my app with the necessary lineEdits and labels and buttons using Qt Creator but I can't figure out where to put in my code that does the actual processing.

    Could you please point me in the right direction? Thanks!
    When you create a new widget, create one with classes (it's an option when adding a new widget). This will not only create a .ui file, but also a .h and a .cpp file that you can use in your application. You can use these files to extend the functionality.

  3. #3
    Join Date
    Dec 2010
    Posts
    2
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Need help writing my first Qt app

    Yes, by native C++ I meant the one with the standard libraries (that runs in the command line).

    Quote Originally Posted by tbscope
    When you create a new widget, create one with classes (it's an option when adding a new widget). This will not only create a .ui file, but also a .h and a .cpp file that you can use in your application. You can use these files to extend the functionality.
    I'm using the Qt Creator and the files that show up on the list on the left are: main.cpp, mainwindow.cpp, maindwindow.h and mainwindow.ui

    I've dragged and dropped the required buttons and labels onto the "mainwindow" I can't seem to add functionality to it. I guess my problem is that I don't know 'where' to write the code for the slot. Say a push button emits the clicked signal, where to I write the slot for the processing that is to take place?

  4. #4
    Join Date
    Nov 2010
    Posts
    15
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Need help writing my first Qt app

    When you create a new project
    1. select the Qt Gui Application
    2. Click On Choose
    3. Enter a Application name
    4. Select Next
    5. Select the base Class as QDialog(if you want to change the name of the class you can clear the first editbox and enter the class name of your choice
    6. Select Next
    7. Finish

    That is all you need to do. There wil be 5 files that will be created
    1. main.cpp
    2. dialog.cpp
    3. dialog.h
    dialog.ui
    trial.pro(i gave the folder name as Trial.pro)

    Hope this helps

    When you create a new project
    1. select the Qt Gui Application
    2. Click On Choose
    3. Enter a Folder name
    4. Select Next
    5. Select the base Class as QDialog(if you want to change the name of the class you can clear the first editbox and enter the class name of your choice
    6. Select Next
    7. Finish

    That is all you need to do. There wil be 5 files that will be created
    1. main.cpp
    2. dialog.cpp
    3. dialog.h
    dialog.ui
    trial.pro(i gave the folder name as Trial.pro)

    Hope this helps

  5. #5
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Need help writing my first Qt app

    Quote Originally Posted by netnut View Post
    I've dragged and dropped the required buttons and labels onto the "mainwindow" I can't seem to add functionality to it. I guess my problem is that I don't know 'where' to write the code for the slot. Say a push button emits the clicked signal, where to I write the slot for the processing that is to take place?
    The code goes into mainwindow.h and mainwindow.cpp
    See the tutorials on doc.qt.nokia.com

Similar Threads

  1. Writing an D-Bus Adapter using Qt
    By BartSimpson in forum Qt Programming
    Replies: 0
    Last Post: 24th March 2007, 15:11
  2. Writing a XML file
    By Djony in forum Qt Programming
    Replies: 7
    Last Post: 5th February 2007, 16:23
  3. Writing Plugins for Qt
    By sarode in forum Qt Programming
    Replies: 4
    Last Post: 29th May 2006, 09:04
  4. [Qt4] writing files
    By patcito in forum Newbie
    Replies: 1
    Last Post: 7th January 2006, 02:41

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.