QTableView scrollToBottom anomaly 

Never call QTableView::scrolltoBottom from slots connected to the model's rowsInserted signal because as the rows added they will start to appear partially:



Connect your slots to the QTableView::verticalScrollBar's rangeChanged signal


[ hozzászólás ] [ 0 trackbackek ] permalink ( 2.9 / 169 )
Poor man's LED in Qt 

Create a square label with fixed size, let's say 24*24px.

Use the following stylesheet:
"background-color: rgb(85, 255, 0); border-radius: 12px;"

Change/clear the stylesheet when the LED is off.
[ hozzászólás ] ( 5 megtekintés ) [ 0 trackbackek ] permalink ( 2.9 / 337 )
A few things what I setup when I create a new Qt Widget project 

1.Add the folowing to pro file:


OBJECTS_DIR = build
MOC_DIR = build
UI_DIR = build
RCC_DIR=build

DESTDIR = bin

and the binaries won't mess up your sorce code directory

2. Make the following modifications in the main.cpp:


#include <QtGui/QApplication>
#include <QtCore/QTextCodec>
#include "mainwindow.h"

int main(int argc, char *argv[])
{
QTextCodec::setCodecForCStrings(QTextCodec::codecForName("UTF-8";));
QTextCodec::setCodecForLocale(QTextCodec::codecForName("UTF-8";));

QCoreApplication::setOrganizationName("MM";);
QCoreApplication::setApplicationName("Mikrotik data miner";);
QCoreApplication::setApplicationVersion("0.1";);

QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}


Why?
The QTextCodec trick is neccessary because the sourcecode is UTF-8 encoded, and if I want to put a string from the code to somewhere I would need to use QString::fromUtf8(). If you do not believe check a generated ui_*.h file.

Always give set the name to your application and the application domain. This is useful when you are using QSettings, you do not need to give constructor arguments when creating a settings object. The settings object constructed in this way always use a separate data area specified by the platform. (.config/QCodeApplication::applicationDomain/QCoreApplication:applicationName.ini on Linux and registry on Windows)


[ hozzászólás ] ( 15 megtekintés ) [ 0 trackbackek ] permalink ( 2.9 / 227 )
Daily Qt sapience - Reading ras files from sequential devices not supported  

I have written a library to get JPG files from a webserver continously. It worked fine with Qt 4.6.3 but with the new Qt 4.7.0 I have get the following error for every frame:


Reading ras files from sequential devices not supported


The workaround is the following:

Turn off the automatic format detection, and set the file format explititly:


imageReader->setAutoDetectImageFormat(false);
imageReader->setFormat("JPG";);


And no more warnings :)
[ hozzászólás ] ( 1 megtekintés ) [ 0 trackbackek ] permalink ( 3.1 / 389 )
Daily Qt sapience - Qt Embedded and tslib 

I have stucked several times with touchscreens and Qt.
My problem's main reason is that I compiled the Qt and tslib outside the openembedded, because I did not liked the Openebmedded's Qt building method. (Build Qt twice once cross compiled, once for the host.)

I have stucked several times in the following situation:
ts_calibrate calibrates, and ts_test works fine, but my Qt app cursor's moves inverse, or it too sensitive or whatever.

Well it seems to be that the various tslibs do not like another,
and their configuration files are not interchangable. And the best one: Qt app likes to work only with the tslib with what it had been compiled.

So if you ran into the similar problem:

Clean up all your existing tslib stuff:

rm -rf /usr/lib/ts
rm -rf /usr/lib/libts*
rm -rf /usr/bin/ts_*


And place your own compiled tslib's binaries, and plugins there.

After then set the following enviroment variables properly of coures:


export TSLIB_TSEVENTTYPE=INPUT
export TSLIB_CONSOLEDEVICE=none
export TSLIB_FBDEVICE=/dev/fb0
export TSLIB_TSDEVICE=/dev/input/touchscreen0
export TSLIB_CALIBFILE=/etc/pointercal
export TSLIB_CONFFILE=/etc/ts.conf
export TSLIB_PLUGINDIR=/usr/local/tslib/lib/
export LD_LIBRARY_PATH=/usr/local/tslib/lib


Run ts_calibrate

And finally run your Qt app with -qws option.

[ hozzászólás ] ( 14 megtekintés ) [ 0 trackbackek ] permalink ( 3 / 411 )

| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Következő> >>

 
számláló