Blog o’ the Jimmy

Just a bunch of stuff I’m into

Browsing Posts in Technology

Since Qt does not have any built in serial communication classes (correct me if I’m wrong please) I’ve fortunately discovered qextserialport found at http://code.google.com/p/qextserialport/ .

It took me a few questions to get it to compile right, but all my questions were answered quickly and very politely . Being a C++ and Qt newbie, I try to research everything to the best of my ability so I can ask educated ( at least I hope they sound like they are ) questions and avoid relying on someone else to hold my hand through something.

My first experience working in the computer industry was doing technical support for a now defunct home shopping network computer manufacturer. My training consisted of a week of being stuffed in a corner watching SNL reruns while my trainer prepared to leave for a new job. The first month working there I had a headache every single day. Most of the questions I submitted to my technical leads were met with rolled eyes and the same question time and time again; ‘didn’t you pay attention AT ALL during your training?’. Fortunately one lead, who bummed cigarettes off me, took the time to work with me and eventually got me up to speed, but the treatment I received from others left a sore spot for quite awhile. A few years later I became a technical lead while working for another company and fortunately caught myself in one of those moments doing the same thing to my techs. Granted, there are some people who will try to avoid taking responsibility at any time, but I was fortunate to have few of those.

Blah blah blah. I am thankful for helpful people, and for people that help themselves.

Even though I’ve upgraded to Qt v4.6.1 when I try and evoke ‘make’ I get “‘make” is not recognized as an internal or external command.  I added to my path the [root]:\Qt\2010.01\qt\bin directory but make.exe wasn’t in there.  (My install directory being [system root]:\Qt)

Well, for Windows I found it in the  [root]:\Qt\2010.01\mingw\bin directory.  The make executable is actually mingw32-make.exe in this directory.  Add this to your Path and use mingw32-make and you should be good to go.

The Trolltech/Prentice Hall book C++ GUI Programming with Qt 4 2nd Edition is a great learners guide, but all the examples use the command line based qmake build tool. I like to do as much through an IDE as I can. So, I’ve decided to document what I’ve had to do differently in order to get the tutorials to work for me using only the IDE. My way may not be the most fluid. I’m learning C++ at the same time I’m learning how to use Qt.

I will not be going over every example, just the one’s where I felt I had a significant ah Ha moment and deviated significantly from the book. But if you find yourself stuck on something let me know and I’ll go over what I’ve done and see if there was any special tweaking needed.

I am using the free open source Windows version of Qt Creator 1.2.1 based on Qt 4.5.3 (32 bit) for learning.

You can download all the books examples at http://www.informit.com/store/product.aspx?isbn=0132354160 I will be only using the examples for Windows.

*Disclaimer: I am in no way authorized to speak for or represent Trolltech/Prentice Hall, Nokia, anyone or anything related to Qt. I’m just a computer geek who thinks that Qt totally rocks.

Okay, so this covers pages 23-29, and the extracted example files found in the chap02/gotocell2 folder :

From page 23: once Qt Creator is started instead of going through the books setup steps do the following-

-Go to File/New and when the dialog box pops up select the option Qt4 GUI Application under Projects and click OK.
-Name the project gotocelldialog and put it in a folder you’ll remember where it’s at, click next
-Make sure QtCore Module and QtGui Module are checked, then hit Next again
-On the Class Information step :
Class name: GoToCellDialog
Base class: QDialog (not QWidget)
Header, Source, and Form files should all be the same name as the Class name except all lower case. Make sure that the Generate form check box is checked and click Next
-Under the Project management dialog make sure that this isn’t going under another project (options should be grayed out) and click Finish

Page 24: now, double click the gotocelldialog.ui file and follow the instructions verbatim to create the GoToCellDialog through the IDE to page 26 where you will run the Form Preview to make sure it looks like the example.

The main.cpp, gotocelldialog.pro, .h, and .cpp files will already have been created.

Page 27: Open gotocelldialog.h . Everything is all set up except for the private slot ‘void on_lineEdit_textChanged(); ‘ declaration, so here is my code with the major change in BOLD-

#ifndef GOTOCELLDIALOG_H

#define GOTOCELLDIALOG_H

#include <QtGui/QDialog>

namespace Ui

{

class GoToCellDialog;

}

class GoToCellDialog : public QDialog

{

Q_OBJECT

public:

GoToCellDialog(QWidget *parent = 0);

~GoToCellDialog();

private:

Ui::GoToCellDialog *ui;

private slots:

void on_lineEdit_textChanged();

};

#endif // GOTOCELLDIALOG_H

—– Notice that in the book example we are not creating the Ui namspace but the IDE is.  The IDE is also creating the private *ui pointer. Important to notice.  Read on.

Page 28:

Open the implementation file gotocelldialog.cpp and add the following code shown in BOLD -

#include “gotocelldialog.h”

#include “ui_gotocelldialog.h”

GoToCellDialog::GoToCellDialog(QWidget *parent)

: QDialog(parent), ui(new Ui::GoToCellDialog)

{

ui->setupUi(this);

QRegExp regExp(“[A-Za-z][1-9][0-9]{0,2}”);

ui->lineEdit->setValidator(new QRegExpValidator(regExp, this));

}

GoToCellDialog::~GoToCellDialog()

{

delete ui;

}

void GoToCellDialog::on_lineEdit_textChanged()

{

ui->okButton->setEnabled(ui->lineEdit->hasAcceptableInput());

}

As you can see here, we need to use ui-> to access the GoToCellDialog objects and methods.

Now, what about the connects for the okButton and the cancelButton?  These can actually be setup in the IDE.  Open gotocelldialog.ui and look in the form editor for the ‘Signals and Slots editor’ tab next to the ‘Action Editor’ tab.  You will add the clicked() Signals and accept()/reject() Slots for the okButton and cancelButton as shown to be entered in the gotocelldialog.cpp .  Once you have created these and saved the changes, they can be found in the ui_gotocelldialog.h file.  Please note that you cannot make changes in the actual ui_gotocelldialog.h file because any changes will be removed when you recompile.

At this point you should be able to build and run the GoToCellDialog example and have it perform as discussed on page 29.

I hope this helps, please let me know if this is clear as mud.

For only $50 you can make a solderless eye tracking setup.

Details and instruction can be found at Instructables.com

The guitar has taken yet another evolutionary leap, this time into our digital age.

A very cool Instructable on how to do your own Structured Light 3D Scanning like Radio Head’s “House of Cards” video.

Point Clouds with Depth of Field from Kyle McDonald on Vimeo.

As quoted from their wiki

HybridTech Energy of Lafayette, Louisiana, USA, sent out an announcement on Nov. 12, 2009 that they are in process of releasing plans to the world for building a water fuel cell that they say produces enough hydroxy gas from water to run a generator to keep the electrolysis cell going as well as producing excess electricity for other use. In other words, it is a self-looped system with excess energy produced in the process.

Links:

OS:Eaton_Water_Fuel_Cell_by_HybridTech_Energy
Fuel Cell plans

Another project I think totally rocks is Stirling Engines. And so, I’ve come across how to make a solar powered one on the Pure Energy Systems Wiki site.

Build a Stirling Solar Engine with off the shelf parts

One of my favorite microprocessors is the Arduino. I came across a project today that combines one of these processors with the ioBridge and an iPod Touch. It hits on a project I’ve got on hold right now while waiting for some funding.