Posts

Showing posts with the label qt

First try to port a Qt application to Sailfish

So last week I prepared v0.3 and put it to git. Yesterday I tried to port it to Sailfish as was the original plan. I went at it as below:  I used an existing test application to get the required files and project settings. I added them to my project. This part included copying various tidbits to the .pro file. Also included is copying over folders for RPM, translations, icons etc.  Then I went through the files and updated the file names wherever needed to reflect my app. This gave me a build which built successfully using the mer-arm toolchain. Now to get it running on the device. I plugged in the Aqua Fish to Laptop with microUSB cord, and enabled debugging. Then tried to debug-run the app. First problem - debug-run doesn't work. I got error as - gdbserver not found. On googling for this, found out I need gdbserver installed on device and it will probably take a while since I'm not familiar with this functionality of Sailfish. So I decided to skip debug-run, and go with only ...

Qt Object Thread Affinity

Image
Example code: https://drive.google.com/file/d/0BxorjNRCBW61ZEJhaEJST1RZa0k/view?usp=sharing For last whole year I have been totally lost between threads, mutexes, shared data, pointers, signals and slots and blah blah blah. Actually I have learned a heck of lot about all these things in these few months. But I think I haven't grasped everything yet. There are many combinations that I don't know work or not. And I think there are many other tricks I am yet to learn especially when it comes to debugging. Anyway, this post is about QThread and object affinity. Well, the typical QThread example is way too simple. They show an object containing one worker function and that worker function running in that thread when they start the thread. Beyond that, nothing! What happens if you call any function on that object, what happens? What about concurrency? What about when the thread is busy? Will the slots get queued up? Lots and lots of questions. But the r...

Debug mode and release mode builds

Recently it just happened that the current product I'm working on had a crisis situation. What happened was testing found a number of inexplicable and inconsistent crashes in the product. We didn't have a debugger back then. So to fix these things, we got gdb compiled for target. Then couple more weeks went by in us trying to find the best way to debug the application. Ultimately we found that autogenerating core dumps for debug mode build is best solution. But as soon as we prepared debug mode build we found a number of other crashes in functionality that's properly working in release mode. To find out the reason, after numerous internet searches, we found there are some initialisation differences in debug mode n badly written code can cause it. So we went back n started fixing it. Now I was thinking about the RCA for this debacle. And I realised that we all were going in the opposite way at this. Basically everybody develops in debug mode and after codebase is stable...

[Qt] Random background color palette

this->setPalette(QPalette(QColor(rand()%255,rand()%255,rand()%255)));

Qt app porting to Android

Part 1 development environment 1. Get MinGW gcc, android SDK, android NDK, jdk, ant, Qt android 5.2(latest at the time of writing this) Add paths to android sdk/bin, sdk/tools, ndk/bin, jdk/bin, ant main dir to PATH. Also define JAVA_HOME to jdk dir. 2. Run android SDK manager, get revision 16, with arm image. 3.  Install Qt android, 4. Create AVD's, check if abi is shown as default/something. This default/ was added in latest revision of sdk, this causes built apps to not run in created AVD. on the net there are tools v22.3 available which will let us create AVD with plain armeabi without default/ prefix. There was a patch for Qt creator which should be available in qt-andrroid 5.3 onwards. 5. Start porting. Open pro file. And go to projects. Disable shadow build. Use correct kit. Try to build/ run it. 6. If your project links against any external lib, you are needed to do following steps. A. Build that lib using Qt-android's provided toolchain for arm. Next use Add library op...

[Qt][Android] In my wildest dreams...(Qt Application on Android)

Yeah! I never thought I would professionally develop for Android! But the powers that pay me, have decided to port our product on to Android and so being the sole person available as of this moment I have been tasked with this enormous task! Hell, I have even got a time line for this! 15 Days! Now, I did visited the washroom afterwards and laughed my arse off!!! Some statistics for the task: Approx 17000 LoC C++ STL/Qt 4-5 shared libraries being used by the project Cross-platform code (Written for Win/Lin as main platforms) PostgreSQL database being used To top it all, the code has never been reviewed, forget about a proper audit. I have worked on parts and I have done my best to clean up about 4000LoC but remaining all is three-four year old crap that would give me nightmares if I dipped my toes in it... Suddenly life has become a war for survival...:D

[Qt] Compiling Qt5.2.1 on Windows 8/VS 2013

Qt5. It's a miasma. It's a beast for me. It's something mysterious. I don't know if I should love Qt5 or hate it. And I think that summarizes my thoughts about Qt5. I first stumbled across the fifth iteration when some functionality in the product I was working on couldn't be done in existing Qt version (4.5.3 btw). So after looking around for the Oracle, I came to know that the functionality can be achieved by moving to Qt5. Now our development platform (WinXP/CentOS 5.3/ Qt 4.5.3) was getting a bit too old. And it was all quite buggy to boot. So we decided to embark on the adventure of upgrading the base. Took us two months to upgrade the Linux side to CentOS6.3/ Qt5.0.1 and port the product to new Qt. But after that other high priority work kept us busy and we never got to get the Windows side up to speed. But then came the fateful day two weeks ago when our IT Manager announced the upgradation of all our faithful old XP systems into Windows 8. And th...

[Qt] Compiling ICU with MSVC (Microsoft Visual Studio)

Link to original article: http://qt-project.org/wiki/Compiling-ICU-with-MSVC Text highlighted and notes added Compiling ICU with MSVC (Microsoft Visual Studio)     Qt 5 / QtWebkit requires ICU.         Pre-built packages     The ICU Project site [ site.icu-project.org ] provides pre-built packages for MSVC 2010, which should work with compilers too. Anyhow, you have to compile your own version if you want to avoid the MSVC 2010 runtime dependency (because you’re using another MSVC version), or want to tailor the ICU configuration.     download.qt-project.org [ download.qt-project.org ] also hosts packages for MSVC 2012 .        

Using QML with C++

Source code  here Original article:  http://www.ics.com/blog/integrating-c-qml Recently I stumbled onto an example where the front end of a small application was written in QML and the backend was done in C++. That was the exact thing I was searching for and it provided a great example of how to get QML and C++ working together. Lets start with the qml:  //-------------------------------------------------------------------------- // SSH key generator UI import QtQuick 2.1 import QtQuick.Controls 1.0 import QtQuick.Layouts 1.0 import QtQuick.Dialogs 1.0 import com.ics.demo 1.0

Another QScrollBar style

Image
Stumbled onto this nice QScrollBar style: QString styleString="QScrollBar:vertical {"     "    border: 1px solid #999999;"     "    background:white;"     "    width:30px;    "     "    margin: 0px 0px 0px 0px;"     "}"     "QScrollBar::handle:vertical {"     "    background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"     "    stop: 0  rgb(32, 47, 130), stop: 0.5 rgb(32, 47, 130),  stop:1 rgb(32, 47, 130));"     "    min-height: 0px;"     ""     "}"     "QScrollBar::add-line:vertical {"     "    background: qlineargradient(x1:0, y1:0, x2:1, y2:0,"     "    stop: 0  rgb(32, 47, 130), stop: 0.5 rgb(32, 47, 130),  stop:1 rgb(32, 47, 130));"     "    height: 0px;"     "    subcontrol-position: bottom;"     "    subcontrol-origin: margin;"     "}"     "QScrollBar::sub-line:vertical {"  ...

Building Qt5 on CentOS 6.3

I am using following method to build Qt5 on CentOS6.3. Make two dir's. Extract Qt source in source dir. Keep following script in home dir. Execute it from there. Also go through configure, make and make install phases one-by-one. #!/bin/sh export QTBUILD=/home/user/qtsource/qt-everywhere-opensource-build-5.0.2 export QTSOURCE=/home/user/qtsource/qt-everywhere-opensource-src-5.0.2 cd $QTBUILD $QTSOURCE/configure -opensource -confirm-license -qt-sql-psql -platform linux-g++ -prefix /opt/Qt-5.0.2 -nomake examples -nomake tests -no-gtkstyle #make -j4 all #make install cd -

A tangle with shared memory

Code: https://drive.google.com/file/d/0BxorjNRCBW61Ri1ib3ZLa2t6Tk0/edit?usp=sharing Recently I was thinking about inter-process communication and especially how to pass/ share data/ information between two running applications. The thing was, I wanted to check out inter-process communication interfaces and see if there was anything Qt provided that I could use.  My requirement is not finalized or anything. The rough idea is to have a channel of communication between two apps. Here my thoughts diverge a bit in that, I am yet not sure of the method of communication. There are two approaches:  1. The message system should be a message board where many processes post messages for each other and periodically access the boards to check out their messages. 2. The message system should be P2P. One process sends a message to another and that message (preferably named) makes other process do something like maybe send an acknowledgement.  Now after digging through the various approaches, ...

Working on Some Qwt Graphs

Image
Link to previous Article  though it doesn't have any code.  This is Link to Code I am back with some more code. Recently I found working on some QWT graphs and as I dug deeper into Qwt I found that it's quite easy to work out something quite functional.  So I developed a small utility to display Qwt's graphs and a small logic that would detect spikes in a data stream.  Here's a screen shot of the actual thing in action. The left graph shows a curve and the right graph shows the detected spikes in that curve. I am showing both up and down-ward spikes.  The time is shown as units and there are some tutorials on how to get correct time to shoe on X-Axis. But here it doesn't matter as this is just a Proof of concept.  I have used a c_sinewave header to get the sinewave and I am introducing spikes using a simple randomizing logic.  On detection part, I have following comments above the block:  // tmp is current ...

Classes for Logging messages to a file and Truncate that file at routine intervals

Code at:  https://drive.google.com/file/d/0BxorjNRCBW61VlVhbllEV0Njb1E/edit?usp=sharing I often used to think that what a simple logging interface would look like. So I went ahead and wrote couple of classes that would do just that.  The classes are simple. First class LogService has two constructors that set the logFileName. This class also has a function logMessageToFile that writes the provided string to the logFile. LogService(QString); void logMessageToFile(QString); Now the second class LogTruncateService has similar constructors. But this class implements a QThread. So we have run function as well. LogTruncateService(QString ); void run(); The run function contains an infinite while loop which keeps checking the time stamps stored in logFile and resets the file after certain no of days are past. Here I have set that time to 10 days. The limitation is that we need to provide log messages in given format. Else this parser fails. But that is feasible when we are only loggin...

Messing with QML

Image
Just started learning QML and yeah, it's totally new age! It's going to take me some time to get in gear and know the various internals.  So I am just messing around and trying to learn the trade lang for Qt 5.

[Qwt] How to plot discontinuous curves

In the current project we are using Qwt for doing some plotting. There was a problem with data loss and how to represent it on the graphs. While discussing possible solutions and researching on how to implement them, I stumbled upon this thread which was good for a solution. http://www.qtcentre.org/threads/49416-How-to-plot-discontinuous-curves-in-Qwt

Extending plugins - a peculiar case

Link to Code Archive I hit upon a very weird scenario recently and found out that there was no easy way to get the plugin working for this scenario. So after searching a while for the possible solution and understanding that the solution would be indeed difficult to implement, I stumbled upon a post that gave me the solution.  The scenario first: consider that there's some functionality in the Plugin container that you want to access from within the plugin. Lets consider a main thread ( GUI thread) refresh function that updates some part of GUI which the plugin provides the data for. And we want to call this refresh from plugin after certain operations in plugin are completed. Lets say that the plugin updates some values and that need updating the main GUI. So we have seen how interface objects let us access plugin functionality and by creative use of base class pointers and container calls how we can access objects and functionality in the plugin. So here we are going to be mo...

Dependency walker

Dependency walker is a great program that tells you what dlls your windows program is using. So you can ship your program with only those dlls and not need to carry a number of unnecessary files.

Day Counter

I wanted to code something small to count days to a particular date from today. So I coded a small app in .net and found it very useful. It's done in about an hour so doesn't have much in terms of functionality. It has the target date hardcoded. But then again considering it's limited scope I didn't go to any more trouble for adding more functionality. Later I tried to do similar things in Qt and succeeded somewhat. There are couple of differences in both apps in that Qt version has colours used for numbers and text. And I have also included past targetted date display functionality in Qt version too. In this case before target date it shows Remaining Days while after target date it shows Past Days. The links are as follows: .Net Project Qt Project

[QT] CREATE AN ODT FILE

Image
/*  **************     CREATING A ODT FILE              ****************  **************     INCLUDE THE NECESSARY FILES     ********/ {     ...     // Text Document Object to hold formatted document     QTextDocument *m_document = new QTextDocument();     // Cursor for traversing the document     QTextCursor m_cursor = QTextCursor(m_document);     // TextTableFormat object for table formatting     QTextTableFormat tableFormat;     tableFormat.setAlignment(Qt::AlignCenter);     tableFormat.setCellPadding(5);     tableFormat.setCellSpacing(50);     tableFormat.setHeaderRowCount(0);     tableFormat.setBorderStyle( QTextFrameFormat::BorderStyle_Solid);     tableF...