Qt 4.5.2 and Qt Creator 1.2 released, availible on the qt homepage or in a repository.
Qt KDE repository overview
June 2009
June 26, 2009
June 25, 2009
hi
I made an application witch converts binary numbers into decimal numbers and back. It is not hard to write and it is not hard to understand.
If you want my code, just send me an e-mail
First I created a form like this:

Then I created two private slot functions (“in the .h file” you can also define it as a private function or public (slots) function, in this case, it doesn’t matter what you choose)
void convertToBinary(int number); void convertToDecimal();
in the button “Dec to Bin” I write (“in the .cpp file”)
convertToBinary(ui->decimalEdit->text().toInt());
in the button “Bin to Dec” I write
convertToDecimal();
NOTE: you also can write the full code into the buttons self, but if you are making bigger projects (300 rows + ) it is quite useful you define them as a function.
you write into the “convertToBinary” function
QString output;
do
{
output.prepend(QString::number(number % 2));
number /= 2;
} while (number <= 1);
ui->binaryEdit->setText(output);
into the “convertToDecimal” function you type
int zero = 0;
int one = 1;
for (int i = ui->binaryEdit->text().length() - 1; i >= 0;--i) {
if (!ui->binaryEdit->text()[i].isNumber()) {
ui->decimalEdit->setText("ERR");
return;
}
if (ui->binaryEdit->text()[i] == '1') {
zero += one;
}
one = one *2;
}
ui->decimalEdit->setText(QString::number(zero));
If you need help, just write a comment or write me a mai (you can find it in on the “Contact” page)
June 15, 2009
In the last 2 two times I showed you how to configure Qt Creator, but not how to create a working project.
The best example for beginning a new language is the “Hello World” example, so let’s start.
1. a GUI example:
“File” –> “New”

–> “Qt4 GUI Appication”

–> set the name and the folder

–> leave as it is

–> set the class, in this case “QWorld” (doesn’t have to be QWorld you also can set “HelloWord” or whatever)
now it should look like this

–> click on “qworld.ui” to form the design, we use a “QPushButton”
–> set the Text on the button with a double click on it, write “Hello Word”

–> right click on the button –> “go to slot” –> “clicked() QAbstractButton” –> “ok”
Now you are in the editor of the “qworld.cpp” file.
type:
void QWorld::on_pushButton_clicked()
{
QMessageBox messageBox;
messageBox.setText("Hello World");
messageBox.exec();
}

–> before it works we have to add the QMessageBox library into the qworld.h file include it as the library “QtGui/QMainWindow” is included.
#include <QMessageBox>

–>Now we can start the project (with CRTL+SHIFT+R or the arrow green Arrow button) and here we are

2. a commandline example:
This is easier, because you don’t have to do as much as on the GUI example (yes it is not much, but for beginning
)
–> Now start like in the GUI example with (CTRL+N or “File” –> “New”)

–> “Qt Console Application”

–> set the name, in this example I called it “QCommandWorld”

–> leave again as it is and then finish
–> go to “main.cpp” and write there
1. under “#include QtCore/QCoreApplication”" we have to include the “iostream” library.
#include <iostream>
2. we just write under “QCoreApplication a(argc, argv);” the little text:
std::cerr << "Hello World!" << std::endl;

–> and then start (CRTL+SHIFT+R or the green arrow button)
Maybe you have to save manually (CRTL+S)
If you want to start the console application out of Qt Creator, just type in the console “./QCommandWorld” and it will show you a “Hello Word!”
2 sorries: my Qt Creator is in German and I worked on a 10″ (1024×600) screen, so not every picture will be so clear, to see everything, but if something isn’t clear, just ask.
Here the whole code to download: here
June 12, 2009
Brainfuck – The next programming language
Posted by sts301 under Other languages, ProgrammingLeave a Comment
Hi
During an informatics lesson, my teacher showed me in Wikipedia, the programming language Brainfuck and told us arrogantly, that we should try to write our name in Brainfuck.
I tried it, with this online compiler and the “Hello World” Example from the wiki.
After 15 minutes or so I checked how this programming languages works. For example:
- You start with letter “a”
- then you have to write as often “+” or “-” to get the wanted letter.
After another 15 minutes I did it:
++++++++++ [ >+++++++>++++++++++>+++>+<<<<- ] >++. >+. +++++++. . +++. >++. <<+++++++++++. >----------. ---. -. ++++++++++++++++++. +. -----------. --------. +++++++++++++. >+. >.
This bunch of code writes: “Hello Sebastian!”
On the page with the online compiler are also examples like “2+3=5″ and so on.
I don’t take charge of, if you get after programming with this language into hospital.
June 11, 2009
Hi
SVN is great for everyone, if you are programming alone with two computers it is easier to copy the code and it also makes it also easier to share the code with other people, instead of uploading it every time. If you are programming in a team, svn is a function, you can’t live without.
For sure, there is also git as an option, but I use svn.
To set the svn settings and/or getting uploaded files, you can use 2 way (or possibly more).
- by command line, enter your programming folder, like “/home/suse/C++/” and there enter “svn co <url>” and it would work, for example a sourceforge hosted svn “svn co https://susenews.svn.sourceforge.net/svnroot/susenews” and it will work.
- by an application, for example KDESVN (I use it and I am happy with it), but with other applications it should work like that way. Open the Repository (CRTL + O) and enter the URL. After that it shows you all files and folders. Click in the menuBar on “Subversion” –> “Repository” –> “Checkout current repository path” –> enter your programming folder, like “/home/suse/C++/” and then click “Ok”.
After that you will see, that you have a folder called your project file name.
Now start the project file “.pro” and wait until Qt Creator started.
Now go to the menuBar “Tools” –> “Options” –> “Version Control”, there enter your username (normal written) and password. (Only if you want to upload files)
Now you are ready for coding!!!
To go to the subversion controll of the Qt Creator, go to “Tools” –> “Subversion”.
There are a couple of functions:
- add “file” = you add the file to the subversion
- delete “file” = you delete the file from the subversion
- diff Project/”file” = you diff the Project/”file” from your computer with the file from the server
- commit All Files/”file” = you upload the your newest file(s) to the server
- Filelog = show the logfile, what’s been done all the times on this file
- Describe = set the revision number of the project/file
- Project Status = shows the logfile of the project
- Update Project = downloads the new files from the server, if they exist
!!One of the reasons why I use a KDESVN, is that Qt Creator can’t upload extern files (like images) directly to the server, so I do it with KDESVN!!
I hope this tutorial helps.
Sebastian
June 11, 2009
Hi
Which category would you like to be better or do you have global wishes. PLEASE write a comment, because we don’t have anything, except that someone in the WWW doesn’t like something on the news, but nobody knows what the user doesn’t like.
June 10, 2009
Hi
I often read that people want to start with Qt/C++, but they don’t know what they should have for a troublefree work.
First for every non-KDE user, Qt SDK itself.
I often heard that the users just download the binary from qtsoftware.com and then they install it, but please don’t do it like that.
2 reasons:
- The Qt openSUSE repository is really uptodate
- It is adapted to openSUSE (I don’t know if there are differences between the binary from the Qt homepage, but please use the repository!!)
The Qt repository I use is qt 4.5 (this repo is for openSUSE 11.1, so if you have an older version, just write instead of “openSUSE_11.1″ your version).
Then download all needed files (I think this happens automatically, if it doesn’t ask me what to do) and if you want to install the Qt IDE, install also the “qt-creator” rpms.
So I you have everything installed you can start programming!!
Another Linux Qt IDE would be KDevelop.