Saturday, May 4, 2013

Qt5: how to design a translucent GUI using an image file

designed a translucent background image on GIMP, loaded the png file on qresource and using some Qt attributes was able to make the original window transparent,
the output result looks like this


Qt 5 code showing how to use Linguist and how to install user defined font

using QFontdatabase and QFont we can use font that is not install on our system on a Qt5 application, we simply load the font using QFile and add it font database. 


Saturday, October 27, 2012

Real time graph using SDL/C++



#include <iostream>
#include <windows.h>
#include <deque>
#include <SDL/SDL.h>
#include <SDL_draw.h>
#include <cmath>

using namespace std;

Draw a graph using SDL/C++

Drawing a graph on an x, y plane... you can disregard the load image function, remember i am using the sdl_draw.h library, which is freely available on the sdl website, but you can also implement the draw line and draw pixel function  yourself. This program is helpful in making a real time graph, just like the one you see on windows task manager under performance tab.

#include <iostream>
#include <string>
#include <deque>
#include <SDL/SDL.h>
#include <SDL/SDL_draw.h>
#include <SDL/SDL_image.h>
using namespace std;

Friday, September 28, 2012

"UINT64_C was not declared in this scope" issue on Code::Blocks fix

To fix the problem include the macro definition INT64_C(c) (c ## LL) and UINT64_C(c) (c ## ULL) before including the ffmgep library.

#include <iostream>

#ifndef INT64_C
#define INT64_C(c) (c ## LL)
#define UINT64_C(c) (c ## ULL)
#endif

extern "C"{
#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
}

int main(int argc, char *argv[])
{
   av_register_all();



    return 0;
}


Sunday, September 16, 2012

Draw a circle using SDL Pixel Manipulation using C++/SDL

The function draw a circle and a second counting arrow and redraw the circle every second, the parameter time hast to initialized  outside the while loop. 

void putpixel(SDL_Surface* screen, int x, int y)
{
    Uint32 *pixel = (Uint32*)screen->pixels;
    Uint32 *p = pixel + y*screen->pitch/4 + x;
    *p = SDL_MapRGB(screen->format, 0x00, 0x64,0x00);
}


void DrawCircle(SDL_Surface* screen, float time)
{
    for(int i = 0; i<=360; i++)
    {
        putpixel(screen, (200 + (100*cos(i))), (100 + (100*sin(i))));
    }
    for(int j = 0; j<=100; j++)
    {
        putpixel(screen, (200 + (j*cos(time))), (100 + (j*sin(time))));
    }
    Sleep(1000);
}

How to create Custom push button in QT5

To be honest this is not my work its an exact copy from this link. http://mcmtechtips.blogspot.com/2012/03/shape-qpushbutton-in-your-own-st...