In this paper, we present a characterization of (binary and non-binary) quantum error-correcting codes. Based on this characterization, we introduce a method to construct
p
p
-ary quantum codes using Boolean functions satisfying a system of certain quadratic relations. As a consequence of the construction, we are able to construct quantum codes of minimum distance
2
2
. In particular, we produce a class of binary quantum
(
(
n
,
2
n
−
2
−
1
2
(
n
−
1
(
n
−
1
)
/
2
)
,
2
)
)
((n,2^{n-2}-\frac 12{n-1\choose (n-1)/2},2))
-codes for odd length
n
≥
5
n\ge 5
. For
n
≥
11
n\ge 11
, this improves the result by Rains in Quantum codes of minimal distance two, 1999, showing the existence of binary quantum
(
(
n
,
3
⋅
2
n
−
4
,
2
)
)
((n,3\cdot 2^{n-4},2))
-codes for odd
n
≥
5
n\ge 5
. Moreover, our binary quantum
(
(
n
,
2
n
−
2
−
1
2
(
n
−
1
(
n
−
1
)
/
2
)
,
2
)
)
((n,2^{n-2}-\frac 12{n-1\choose (n-1)/2},2))
-codes of odd length achieve the Singleton bound asymptotically. Finally, based on our characterization some propagation rules of quantum codes are proposed and the rules are similar to those in classical coding theory. It turns out that some new quantum codes are found through these propagation rules.