PDA

View Full Version : Need help writing my first Qt app



netnut
16th December 2010, 08:43
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!

tbscope
16th December 2010, 08:50
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.

netnut
16th December 2010, 11:35
Yes, by native C++ I meant the one with the standard libraries (that runs in the command line).


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?

chandru@080
16th December 2010, 11:46
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

tbscope
16th December 2010, 11:52
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