excuse me if this question has been asked before than i am sorry i couldn't find it.
so i am ruining Ubuntu on my desktop computer and i have started c++ using code blocks i was wondering how do you make a GUI window for Linux or am i using the wrong tool for the job?

You can use Qt. Do this in a terminal window:

$ sudo apt-get install libqtcore4 libqtgui4 libqt4-dev qt4-qmake qt4-doc qt4-demos qt4-assistant qt4-designer qtcreator qtcreator-doc

Some of the above might be redundant, but what the heck. And most of it is probably installed already as part of the distro or as dependency of other, already installed packages (since Qt is pretty wide-spread in Linux GUI world).

At that point, you should be able to make a project like this one:

#include <QApplication>
#include <QWidget>

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

    QWidget window;

    window.resize(250, 150);
    window.setWindowTitle("Simple example");
    window.show();

    return app.exec();
}

Save it to file "simple_example.cpp", go to that directory in a terminal, and run:

$ qmake -project
$ qmake
$ make
$ ./simple_example

If the above works, and it should (in the tradition of Linux being automatic and easy), then your setup is working, at least basically (you can browse synaptic for anything that starts with "libqt" for more plugins and add-ons, like opengl, sql, xml, svg, etc.). The above is just a simple example, the more usual approach is to design the GUI window using Qt Designer (by dragging and dropping GUI elements, instead of having to code everything in), save it to some .ui files, implement some event handlers (called "slots" in Qt), and create a qmake project file. It is a slightly more involved building process, but nothing to be afraid of.

There are plenty of tutorials on Qt. Like this, or that, or this.

I think the easiest way to make a window, or a simple game is using allegro4.2 or 4.3:

sudo apt-get install liballeg4.2-dev

or

sudo apt-get install allegro4.2-dev

.
Then open Code::Blocks and find linking in the settings adn put

`allegro-config --libs`

. Now you are ready to use Allegro:

#include <allegro.h>
/*On windows*/ #include <winalleg.h>
using namespace std;

int main(void) {
    allegro_init(); /initialize window
    install_mouse();
    install_keyboard();
    SET_GFX_MODE(GFX_AUTODETECT_X,y,z,0,0); 
/ X - WINDOWED / FULLSCREEN
/ y,z - e.g. 640,480/800,600/1024,768/1280,960 ... as u wish it can be 100,1 too :D
/then find some sites with tutorials, but it is like pascal:
color = makecol(r,g,b);
line(x1,y1,x2,y2,color); 
}

You can code your GUI if you prefer but you can use Qt 4's Designer(good luck working with it I find it much easier to hard code it then to use the designer) as far a Gui libraries in general take a pick out of the litter you got GTK, QT4, WxWidgets as the main libraries and then you've got the cross platform SDL.

I can't really decide on which one is "easier" I like QT4's simplicity but alot of the documentation is obscure meaning your going to have to put it together which could take a while(depending on how complex the GUI needs to be) unless you use the gui QT designer but then you've got to learn how to use it.

if you just need a simple dialog you can use XDG

sudo apt-get install xdialog
or
pacman -Sy xdialog


for documentation on xdialog

man xdialog or xdialog --help or google.

thank you guys for all the help i'll see if it works :)

any time :P there are a couple of other ones but they aren't worth mentioning because they are kinda outdated and never worked on actively.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.