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)
buff=new char ;
buff1=new char ;
buff=ctime(&ticks);//buff now contains the date and time details
struct passwd *pwd;
pwd=getpwuid(getuid());//to get the usr name
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);