1+1=10

记记笔记,放松一下...

Install Bugzilla on Windows

According to the documentation of Bugzilla 5.0, the following applications should be installed first:

  • ActiveState Perl 5.18.2 (5.12.4 or higher)
  • Apache 2.4 (2.2.x or higher)
  • MySql 5.6 (5.0.15 or higher)

Download Bugzilla

1
git clone --branch 5.0 https …

Hello Pelican

Octopress is a great blog system, but it's not easy to maintain for users who don't familiar with ruby. So I switch to Pelican, which is written in Python.

“Pelican” is an anagram for calepin, which means “notebook” in French. ;)

Notes on OpenSSL and Qt

In Qt, working with SSL can be frustrating because of the inconsistent naming of the corresponding binary dynamic libraries, and Qt defaults to dynamically loading them, without providing any indication if they are missing.

Libraries name of openssl?

The "library" portion of OpenSSL consists of two libraries.

On posix system …

How to use QThread in the right way (Part 2)

There are two way to use QThread:

  • Subclass QThread and reimplement its run() function
  • Use worker objects by moving them to the thread

As the QThread::run() is the entry point of worker thread, so the former usage is rather easy to understand.

In this article, we will try to …

How to use QThread in the right way (Part 1)

A short history

Long long ago, subclass QThread and reimplement its run() function is the only recommended way of using QThread. This is rather intuitive and easy to used. But when SLOTS and Qt event loop are used in the worker thread, some users do it wrong. So Bradley T …

left shift operator overloading for QDebug()

Consider that we have create a custom type:

1
2
3
4
5
6
struct Point
{
Point(int x, int y):x(x),y(y){}
int x;
int y;
};

If we want to make it work with qDebug(), we need to implement a streaming operator:

1
QDebug operator<<(QDebug dbg …

Link Confilict between SDL and Qt under Windows

Someone complain that, when using SDL and Qt in the same project under Windows, the linker will generate link error.

SDLmain.lib(SDL_win32_main.obj):-1: error: LNK2005: _WinMain@16 already defined in qtmaind.lib(qtmain_win.obj)

What happened behined this?

1
2
3
4
5
6
#include <QApplication>
#include <SDL …

Redirect current process's stdout to a Widget such as QTextEdit

Note:

  • Source code can be got from https://github.com/dbzhang800/StdoutRedirector
  • This class can only be used in Qt5, as QWindowsPipeReader which is introduced in Qt5.0 is used.

Implementation

Windows

  • Normally, we need to create pipe with CreatePipe(), then attach stdout to it's write end with SetStdHandle(), then …

Qt Macro: Q_DECLARE_INTERFACE

Q_DECLARE_INTERFACE(InterfaceClassName, InterfaceId)

This macro associate the given InterfaceId to the interface class called InterfaceClassName.The macro is normally used right after the interface definition:

1
2
class MyInterface {};
Q_DECLARE_INTERFACE(MyInterface, "me.debao.qt.myinterface")

Q_DECLARE_INTERFACE is a macro that defines helper function that make qobject_cast(QObject *object) return a …