Category Archives: Qt


qt 4里
QString str("hello");
",; //只打印出h
1. printf("%s
", qPrintable(str));
2. printf("%s
", str.toLatin1());
//toLatin1,toUtf8,toLocal8bit返回QByteArray,可以自动转成 char*

compile qt with

1. unzip opensource version

//2. run configure with win32-g++ // obselete, a good methods here

3. should merge with, then overwrote by files from mkspecs-from-evaluation-version

4. set qmakespec to
4.1 rename the License.cpl to license.TROLL
4.2 copy qmake-from-eval to qmake dir, rename to qmake.exe
4.2 open the makefile under the qmake dir, comments the all: xxx line, and then add a line "all: "
4.3 run configure, it will configure for you.

5. use qmake -recursive to generate makefiles (in general, this step
will be done during the configure process. but, if you run with any
other makespec rather than, please do it again. In a clean installation, it’s ok to skip this step)

6. nmake all files, it will cost much time. but, you can stop it at any
time, and then simply run nmake again to continue the process.

qt 4 installed with and dev-c++

qt 4 installed with and dev-c++

adipose from qt forum has summerized some points in how to compile qt 4 source open version with here is its url

this thread also address some ideas on how to make qt4 work with dev-c++. apart from this thread, there are some as following:….html

hope to help.

compiling Qt 4 with (obselete)

see this item for latest method

1. unpack to c:qt4.0.0
2. open cmd, then locate to c:qt4.0.0

cd qt4.0.0

3. unpack to the Qt 4.0.0 directory
4. configure Qt 4 with MinGW. This step is necessary, otherwise it will prompt missing of files when do nmake.

configure -platform win32-g++

5. go to the qmake directory, then use Makefile.win32-msvc to recompile qmake.

cd qmake
nmake -f Makefile.win32-msvc
am also wondering if there is a makefile for
Unfortunately, there is not such a file due to absence of qmake
generator file specific to However, we can regard qmake using
win32-msvc option is compatible with environment, considering
the successful final nmake link result.

6. go back the root directory of Qt 4. Using qmake with recursive
option to produce makefiles in current directory and all its

cd ..
qmake -recursive -spec

7. nmake Qt4. The process will be longer than you expected. Be patient. 🙂


编译是变态的慢,要有心理准备哦!我在dell c640/2.0G/512M上花了将近6个小时才编译完成

If you need, please leave me a message, or drop me an
Email. You can also download this file from Kde-cygwin maillist. Thank
Andreas Hausladen for sending this zip file to the public maillist.

p.s. It will be better to use makespec files got from the win
evaluation Qt 4 version. Just override the counterparts in I have done as this, and comipled successfully.

qt 4推出在windows平台下的GPL版

可惜不支持ms VC++或,网上已经有一些讨论,看是否将qt opensource版在
在这个邮件列表里可以搜索到一些 关于此话题的技术讨论


const QString& PmKeywords::Keyword()
return keywords.toString();
而 这里,keywords被定义成QValueVector,toString返回QString。大家明白问题出在哪 了吗?由于toString返回QString,而不是QString&,是局部变量,而Keyword属性返回QString&,是一 个引用,即是将局部变量的引用返出来了,但局部变量在scope出了后,就被销毁,这样返出来的就是一个无效的引用。由于整个代码已经近5000行,查错 查起来很麻烦,好歹还是找着了,前面还一直怀疑是否QSqlCursor有问题,在进行QSqlCursor Update的时候发生错误,但根本在于上面描述。一个教训,轻易不要怀疑这些大公司写的商业代码,只能从自己的代码上找原因,这样也许会更有助于除错。


QLable: 显示文字或图片,不提供用户交互
QSimpleRichText: 用于显示由stylesheet定制的rich text,一但构造完成,不能被修

QTextEdit: 支持修改和显示rich text
QTextBrowser: 支持显示rich text,适合有超文本接连的场合,不能被修改。