Qt noob needs help in making simple Qt application
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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"
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'];
Hopefully that's easy enough to follow. Making the path to where I want the file first, then setting up the file name, then creating the file, opening it, writing this "stream" to it and finally closing the file.
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"))
{
if (hpVariables[Offset].VarType=="enum")
FileName = TypeDirectory + "/enum_val";
else if (hpVariables[Offset].VarType=="bitmask")
FileName = TypeDirectory + "/bit_val";
QFile f2(FileName);
i = f2.open( IO_ReadOnly );
QTextStream OpenStream( &f2 );
j=0;
while (!f2.atEnd())
{
s=OpenStream.readLine();
hpVariables[Offset].ParamNames[j] = s;
++j;
}
hpVariables[Offset].ParamQuantity = j;
f2.close();
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.