Colorgcc is a perl script that makes the error and warning message of gcc be highlighted by different color. Nice tool from Johannes Schlüter.
>wget http://schlueters.de/colorgcc.1.3.2.txt
>mv colorgcc.1.3.2.txt colorgcc
>mkdir /usr/local/bin/colorgcc
>mv colorgcc /usr/local/bin/colorgcc
>cd /usr/local/bin/colorgcc
>ln -s ./colorgcc g++
>ln -s ./colorgcc gcc
>export PATH=/usr/local/bin/colorgcc:$PATH
2009-09-26
2009-09-22
Compile with Qt State Machine Framework
1) You need to download Qt State machine Framework
2) >tar xvzf $(QtStateMachine).tar.gz
3) In your .pro file add a line:
include($(QtStateMachineInstalledPath)/src/qtstatemachine.pri)
4)> qmake then make
2) >tar xvzf $(QtStateMachine).tar.gz
3) In your .pro file add a line:
include($(QtStateMachineInstalledPath)/src/qtstatemachine.pri)
4)> qmake then make
Color Highlight in VIM
"A color editor like Vim can improve the productivity of programmers by 2 to 3 times!!"
>apt-get install vim
Add following lines into ~/.vimrc
>apt-get install vim
Add following lines into ~/.vimrc
" Set syntax highlighting to always on
syntax enable
" Set the background to dark and the colorscheme to murphy
set background=dark
" Set automatic filetype detection to on
filetype on
Change Qt Widget Background
Qt Widget's Background is changed by setPalette(QPalette);
The "Qt Tutorial 8 - Preparing for Battle" is changed: add a button to change the background color of ConnonField.
========
main.cpp:
========
===========
cannonfield.cpp
============
The "Qt Tutorial 8 - Preparing for Battle" is changed: add a button to change the background color of ConnonField.
========
main.cpp:
========
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent)
{
QPushButton *quit = new QPushButton(tr("Quit"));
quit->setFont(QFont("Times", 18, QFont::Bold));
QPushButton *change = new QPushButton(tr("Change"));
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
LCDRange *angle = new LCDRange;
angle->setRange(5, 70);
CannonField *cannonField = new CannonField;
connect(angle, SIGNAL(valueChanged(int)),
cannonField, SLOT(setAngle(int)));
connect(cannonField, SIGNAL(angleChanged(int)),
angle, SLOT(setValue(int)));
connect(change, SIGNAL(clicked()),
cannonField, SLOT(changeBackground()));
...
}
===========
cannonfield.cpp
============
...
void CannonField::changeBackground()
{
setPalette(QPalette(QColor(0, 250, 200)));
update();
}
...
2009-09-21
Fullscreen Qt widget
If your Qt executable is the single application running at your embedded system. It makes sense that your Qt widget is border-less and full-screen.
Max modifies the example in Qt tutorial 4:
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
};
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent, Qt::FramelessWindowHint)
{
//setFixedSize(200, 120);
QPushButton *quit = new QPushButton("Quit", this);
quit->setGeometry(62, 40, 75, 30);
quit->setFont(QFont("Times", 18, QFont::Bold));
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyWidget widget;
//widget.show();
widget.showFullScreen ();
return app.exec();
}
Compile the code using Embedded Qt and run the binary among qvfb (See "Program and Test Qt Embedded Code on PC - virtual framebuffer"). The following snapshot is at 240x320 PDA configuration.
Max modifies the example in Qt tutorial 4:
class MyWidget : public QWidget
{
public:
MyWidget(QWidget *parent = 0);
};
MyWidget::MyWidget(QWidget *parent)
: QWidget(parent, Qt::FramelessWindowHint)
{
//setFixedSize(200, 120);
QPushButton *quit = new QPushButton("Quit", this);
quit->setGeometry(62, 40, 75, 30);
quit->setFont(QFont("Times", 18, QFont::Bold));
connect(quit, SIGNAL(clicked()), qApp, SLOT(quit()));
}
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
MyWidget widget;
//widget.show();
widget.showFullScreen ();
return app.exec();
}
Compile the code using Embedded Qt and run the binary among qvfb (See "Program and Test Qt Embedded Code on PC - virtual framebuffer"). The following snapshot is at 240x320 PDA configuration.
Use Class Declaration in C++ Header File
A good C++ programmer always seeks to let his header files as slim as possible. The following header file is a bad example, in which an unnecessary header file is included.
This makes the compilation of big projects much slower, because the compiler usually spends most of its time parsing header files, not the actual source code. As suggested in the comments, use a class declaration instead including a header file. The final binary files are same as before, but this trick alone can often speed up compilations by a factor of two or more. Belows are the example of declaration of the template class and class with namespace:
#ifndef MYCLASS_H
#define MYCLASS_H
#include <SuperTime>
//bad, slow down the compilation
#include "Number.h"
//good. class declaration is sufficient for a pointer variable
//class Number;
class MyTime : public SuperTime
{
public:
MyTime(SuperTime *parent = 0);
int value() const;
void setValue(int value);
void valueChanged(int newValue);
private:
Number *number;
};
#endif // MYCLASS_H
This makes the compilation of big projects much slower, because the compiler usually spends most of its time parsing header files, not the actual source code. As suggested in the comments, use a class declaration instead including a header file. The final binary files are same as before, but this trick alone can often speed up compilations by a factor of two or more. Belows are the example of declaration of the template class and class with namespace:
template < class L > List;
namespace card {
class MainBrowser;
}
2009-09-11
State Machine in Qt
Qt provides a two classes to implements state machines.
QtStateMachine offers the basic APIs for state machine mechanism, while QtScriptedStateMachine is a subclass of QtStateMachine and adds the missing parts to support SCXML. Max tried to implement the following state machine. The code is not yet tested, ;) Hope it works!

Reference:
QtStateMachine offers the basic APIs for state machine mechanism, while QtScriptedStateMachine is a subclass of QtStateMachine and adds the missing parts to support SCXML. Max tried to implement the following state machine. The code is not yet tested, ;) Hope it works!
//selection state groups
QtState *pStateSelection = new QtState();
QtState *pStateSearch = new QtState(pStateSelection);
QtState *pStateBrowse = new QtState(pStateSelection);
pStateSelection->setInitialState(pStateBrowse);
//processing state groups
QtState *pStateProcessing = new QtState();
QtState *pStateMaterial = new QtState(pStateProcessing);
QtState *pStateProcedure = new QtState(pStateProcessing);
pStateProcessing->setInitialState(pStateMaterial);
//transitions from "Selection" state
pStateSelection->addTransition(buttonStart, SIGNAL(clicked()), pStateProcessing);
//transitions from "Browse" state
pStateBrowse->addTransition(buttonSearch, SIGNAL(clicked()), pStateSearch);
//transitions from "Search" state
pStateSearch->addTransition(buttonOK, SIGNAL(clicked()), pStateBrowse);
pStateSearch->addTransition(buttonCancel, SIGNAL(clicked()), pStateBrowse);
//transitions from "Processing" state
pStateProcessing->addTransition(buttonFinish, SIGNAL(clicked()), pStateSelection);
pStateProcessing->addTransition(buttonCancel, SIGNAL(clicked()), pStateSelection);
//transitions from "Material" state
pStateMaterial->addTransition(buttonProcess, SIGNAL(clicked()), pStateProcedure);
//transitions from "Procedure" state
pStateProcedure->addTransition(buttonMaterial, SIGNAL(clicked()), pStateMaterial);
//start the state-machine
QtStateMachine oMachine;
oMachine.addState(pStateSelection);
oMachine.addState(pStateProcessing);
aMachine.setInitialState(pStateSelection);
oMachine.start();
Reference:
Subscribe to:
Posts (Atom)