Saturday, January 5, 2013

Add control on Qt GUI and assign Signal/Slot graphically.

Last post describe how to new a empty Qt Gui Application. Base on the generated project, we are going to add a button graphically.

- Double click to open mainwindow.ui under Forms of our project in the Projects box. With .ui file selected, we can switch between (text) Edit View and (graphically) Design view, by click on the Edit/Design button on the left side bar.


- With Design View opened and make sure the Edit Widgets (F3) button is pressed, we can drag any widget from the left selection box to the design pane. Lets drag to add a Push Button. And double click on the text over it to edit text property to "Hello Qt".

Now, we can assign SIGNAL and SLOT to the Push Button to close the Window.

- Click on the Edit Signals/Slots (F4) button.

- Press and hold mouse left button over the Push Button, and pull a line out to any space, and release mouse button.

- Select clicked() in pushButton(QPushButton) box.
- Check to enable Show signals and slots inherited from QWidget.
- Select close() in MainWindow(QMainWindow).
- Click OK.

Now your Design view will become:

Finally Run your application. Now you can click the Push Button to close the Window.


Create Gui application on Qt 5

- In Qt Creator, click File -> New File or project... to create our new project. Select Projects of Applications, Qt Gui Application and click Choose...

- Enter Name and Browse... to select the location to create your project, Next>

- Accept the default setting of Kit Selection, Class Information and Project Management.



- Qt Creator will create pre-set Qt Gui project for you.

Now you can click Build->Run, or Ctrl R, or click the green arrow button to run the dummy application.


- Next: Add control on Qt GUI and assign Signal/Slot graphically.


Install Qt 5.0.0 on fresh new Ubuntu 12.10

After install Qt 5.0.0 on fresh new Ubuntu 12.10, you will be complained with error: Qt Creator needs a compiler set up to build. Configure a compiler in the kit options.

You have to install g++ on Ubuntu, enter the command in Terminal:

$sudo apt-get install g++

You will face with another error: cannot find -lGL.

To solve it, install OpenGL library. Enter the command in Terminal:

$sudo apt-get install libgl1-mesa-dev libglu1-mesa-dev

Install Qt 5.0.0 on fresh new Ubuntu 12.10
Install Qt 5.0.0 on fresh new Ubuntu 12.10



Friday, January 4, 2013

cannot find -lGL

I have just installed Qt 5 on Ubuntu, and tried my first Hello World. But fail in Build with error of "cannot find -lGL"!

cannot find -lGL


It's OpenGL API missed.

To install OpenGL library, you can install libgl1-mesa-dev and libglu1-mesa-dev using Ubuntu's Package Manager, and also the other required packages.

Open Synaptic Package Manager, search and install libgl1-mesa-dev and libglu1-mesa-dev, and accept install the required packages.

install libgl1-mesa-dev

install libglu1-mesa-dev


After installed, re-build my Qt project, and OK DONE.

Success


Download Open Source Versions of Qt

Download Open Source Versions (none-commercial/FREE) of Qt, visit Qt Project site.