ART OF APP BUILDING IN GNU/LINUX-2:Creating a window with username and time-date info(combining system programming and QT)





Here it is the second post of the series “The Art of app building in GNU/LINUX”.One of the powerful feature of QTCREATOR is that it can interpret HTML codes,in short its HTML aware.This property is used to set the colour and font of the text.
this this post we’ll create a simple app for GNU/LINUX, A basic window displaying User name and the time-date info,here goes the tutorial , happy coding , happy hacking ..

Create a Empty Qt project as shown in the reference video .Add a C++ source file as illustrated in the video, write this piece of into it and run .


int main(int argc,char *argv[])
    char *buff,*buff1;
    buff=new char [100];
    buff1=new char [1000];
    time_t ticks;
    buff=ctime(&ticks);//buff now contains the date and time details
    struct passwd *pwd;
    pwd=getpwuid(getuid());//to get the usr name
    QApplication app(argc,argv);
    strcat(buff1,”<font color=blue><h2>HI “);
    strcat(buff1,pwd->pw_name);//obtaining the user name

/*only one string is supposed to be passed onto Qlabel to display it in the window
  so the strings are concatenated to form one big string with HTML code for font and
  colour with user name   and date-time information*/

    QLabel *label1=new QLabel(buff1);

    return app.exec();


My First Experience on Creating GUI in GNU/LINUX using QT creator

Every piece of software around us have interfaces , may it be on your mobiles,ATM Machines  ,Music players , Television Sets, not to mention everything on your Computer from Apps to your desktop environment .So creating a Interface for software is no longer a rare requirement , its a part of Almost every Software .Here is my first go at creating GUI based softwares in Linux …..Try QT Creator ,the advantage  with this is that you will be writing  same piece  of code in Windows , Linux and MAc OS to create GUI environment ……Qt creator is very simple and easy to use , Using QT requires Basic knowledge of Object Oriented Programming concepts (If u have programmed previously in JAVA , C++ or in PYTON , you can  easily start learning to program in QT Creator . In Ubuntu Linux , Qt Creator can be directly installed from software centre , or else Qt creator binary is Available for Download at .If you are interested in learning GUI programming using QT here is the link for good series of video lectures on it …..

Running the Binary file which was created after building the code in Qt creator  which gave a GUI window with a Push Button by name “MYSTIXZ” !!!

 Image     A look Around QT Creator in GNU/LINUX  -1Image     A look Around QT Creator in GNU/LINUX  -2