Qt noob needs help in making simple Qt application
I wish to write a small image resizing application (front-end to imageMagic's 'convert'), but I am total noob in Qt and linux dev tools. Not total noob though (senior Delphi and Adobe Flex/AS3 developer). I have basic knowledge of C++ and Python.
So I took Qt4 designer and designed my form, placed signals and slots, saved file, ... and that is about where my knowledge ends. I tried to use KDevelop, but it is complex and create bunch of files, and I couldn't find where to import my UI or how to do it. Then i opened QDevelop which is simpler, could link my UI, but gave me bunch of errors as classnames was not the same as template. Tried to do something in it, but with no success. So, my question is: is there anyone who can teach me how to make an application from an UI form? Since the application is fairly simple, I think it will not take too much time. |
There are a lot of great books about using the Qt GUI toolkit. Coming on here asking for someone to do the work for you or tell you how to do everything, essentially, sounds like you have no initiative. Get one of the books... Also, Qt's own documentation is very helpful. There are many examples and tuturials you can work through.
http://doc.trolltech.com/4.3/tutorial.html |
Can I suggest you use qt-creator?
KDevelop doesn't work on KDE4 and you really need to be developing KDE4 apps now. Get the IDE from here: http://qt.nokia.com/products/developer-tools It has some very nice example projects. It sounds like you've worked out how to place parts, the next thing, that is hard to get your head round at first, is signals and slots. As a very simple example if you have placed a button and a label on your form, you can get the button to affect the label in the following way: Code:
#include "mainwindow.h" Here I have used the qizard to create a new application and added a ui form called mainwindow. I called the pushbutton "rPushButton" and the label, er, "label". The signal is clicked() and it's connecting to the slot on_rPushButton_clicked(). Hopefully that aprt is fairly intuitive. My mainwindow.h file looks like this: Code:
#ifndef MAINWINDOW_H I really do like this new qt-creator. It's fast, not some horrible Java thing like Eclipse and looks really nice. Good luck and come back and ask if you want more help. :) I found this hideously complex when I first had a go and would never have made it without help from a friend. I don't think you have no initiative if you've got as far as you have. |
For a **simple** front-end, why not dialog ( or kdialog, and other variants) or zenity?
Good book including how to write GUIs: http://www.amazon.com/Beginning-Linu.../dp/1874416680 |
Thank you all.
I was lost. Read few tutorials but they dont explain what I need.. just supposing that you know all the tools and "just do it'. I will look into it. It is all confusing in the beginning. @Guitarist88 And no, I didn't ask to be done instead of me (I hate that), just to give me guidelines to start. I have read bunch of tutorials and nowhere to find : "you made your UI, now start working with it by opening "THIS_TOOL and do THIS and THAT" |
@DiBosco, qt-creator is so awesome!!!
I think I will manage to do something in it. Thank you! |
@DiBosco
Yes yes yes! I figured it out, thanks to your example. |
Quote:
This is a useful page: http://doc.trolltech.com/4.3/classes.html |
Believe it or not, my program is almost ready... basic version :)
I will ask you for some things, if I may? |
Quote:
|
I'd like to keep some settings in text file.
For example if I have: # SOURCE=/home/myuser/pictures DESTINATION=/home/myuser/pictures/resized How do I read and write it easily? In Lazarus/Delphi, StringList has property "Values", so I can do like this: MyStringList.values['SOURCE'] = whatever_to_Write whatever_to_read = MyStringList.values['SOURCE']; |
Here's an example of (I hope) what you're asking to do:
Code:
void ordernumber::set_initials(QString s) Bear in mind this is Qt3, so it might be slightly different now. Checkout QTextStream in that link I posted above for more details on what it can do. It's very cool for opening files and quickly parsing them a line at a time. Although in some ways Qt is harder to get to grips with than Delphi at first, I think it's probably more powerful once you get into it. This snippet from a program I wrote to look through dynamically create files when a USB device is plugged in might give you a bit more of an idea. :~) Code:
if ((hpVariables[Offset].VarType=="enum") || (hpVariables[Offset].VarType=="bitmask")) |
O thanks!
Seems that Qt stores variables just as delphi does. I will use your example as a basis for my settings read-write. |
Actually, I find class QSettings which is a real nice way to store your settings. Actually you dont think of anything, and let hard part to Qt...
Usage: Code:
void MainWindow::writeSettings() |
All times are GMT -5. The time now is 05:57 PM. |