Showing posts with label qt4. Show all posts
Showing posts with label qt4. Show all posts

Thursday, February 10, 2011

QWT

QWT stands for "Qt Widgets for Technical Applications". I installed the examples and successfully ran them in Qdevelop (but need to run them in a user folder. I ran into some permission problems in the original directory, /usr/share/doc/libqwt5-doc/examples/.)

The examples were too numerous to study, so I tried to separate one of them from the project. This was more difficult than I thought. The main trick was creating an environmental variable, QWT_ROOT=/usr/include/qwt-qt4 , to be located in my .profile (or .bashrc).  I also had to provide a link to qmake. Using the examples as a, well, as an example, I created two files which contained all the library paths, qwtconfig.pri and myproject.pri.

The sequence at the console is:
  • qmake -project , Creates myproject.pro
  • Edit myproject.pro and add the lines
    • include( myproject.pri )
    • include( qwtconfig.pri )
  • qmake , Creates Makefile
  • make , Creates executable, myproject
  • ./myproject  , Runs executable

Monday, February 7, 2011

Qt Analog Clock

Yesterday, I downloaded and studied the AnalogCLock example on the QT4 website. The first thing experimented with  was changing the color of the hands. That process taught me a bit about the QPainter class, that the function can have 3 parameters (RGB) or 4 (RGB ,alpha). This is something useful about classes. Then, I added another hand to represent the unit seconds. Of course, I had to get it moving. This I did using: painter.rotate( time.second()*6.0);.

During this process, I could not quite get it right, so I decided to print out some numbers. I read about the QTimer class and what it was outputting. The following command printed output to the console (being sure to #include <QtDebug> in the header):

qDebug() << "minute is:" << time.minute() ;

I found that QDevelop does not output anything until the running program closes. I ran the code at a terminal and the output was updated instantly. This is important because I want to understand the event driven nature of QT. Putting in a print statement like "This event has been called" helped me a great deal when I was learnign widgets in IDL.

I found another informational class, QMessageBox which, when used in the following statement, will pop up a window, at the console and from within Qdevelop. This is what I will use.

QMessageBox::information(this, tr("Status"),"Are you ready?");.

Thursday, February 3, 2011

QDevelop or Console

I have been using Qdevelop for over a week now, including the gui Qdesigner for producing a  .ui program. I find that I am not learning anything. I am able to get things to work, but I do not really understand how. This morning, I tried to put the constructor, "void MainWindowImpl::rmdfunction()" into its own file, with a class definition in its same-named .h file. This did not produce a working program. Many errors which I did not understand.

Whenever I look at examples on the Internet, there are a multitude of different programming styles. The overlap between QT3 and QT4 does not help. If I manually enter these programs into an editor, and run them with qmake, they work. But I want to learn the proper or most consistent way to program in QT. That is the reason I am trying to work within the Qdevelop environment.

Monday, January 24, 2011

QT4

I have been working with QT4 this week and have had some success. Thanks to a few tutorials, I was able to create a dialog widget, a pull down menu which when activated, calls the program xeyes. I created this with Qdevelop and Qdesigner.

Screenshot of QT4 Widget

Result of selecting "Open Eyes" in menu.