在寫android app的時候,遇到了一些問題,於是又跑到這邊來記錄一下。
所謂的abstract就是在父類別不實做這個方法,到子類別繼承此父類別時候就可以自由運用(發揮)
ex:
class abstract father
{
public abstract void test(string str);
public void main()
{
String str = "test";
test(str);
}
}
----------------------------------------
class son extends father
{
public void test(String str)
{
//做這邊想要做的事情
//override (覆寫)
system.out.print(str);
}
}
最後在使用的時候可以用
father f = new son();
這樣來宣告
f.main();
則會print 文字test出來
end
2017年4月12日 星期三
2016年12月20日 星期二
[Qt] JSON中Unicode / UTF8 轉換為QString方法
最近需要把JSON格式中的一些資料拿出來
看起來像是這樣:
....
"text": "\u4e00\u6bb5\u5149\u5f71,\u4e00\u6bb5\u65c5\u884c\uff0e\n\n #\u4e58\u8457\u5149\u5f71\u53bb\u65c5\u884c\n #travel\n#light",
.....
(前後文就不特別放在這邊了,不重要)
那這種\u4e00\u6bb5... 取下來會是個QByteArray ,先把它們轉成QString
但還是一大串阿! 於是再用QString裡面的split -> QStringlist來承接。
所以現在可以切開變成u4e00,但這還是一個UTF8,所以我們需要再做調整
上網找了很多方法都沒有找到,但是找到了一篇 這裡 於是終於找到方法了!
解決方法其實很簡單:
不管怎麼弄,反正把\u (escape) 這兩個字元弄掉(QString::replace / QString:: remove)
剩下4e00
QString t1 = "4e00";
int Hex = t1.toInt(0, 16);
QString t2 = QChar(Hex);
你會發現t2 就轉成你要的字元了!
如此簡單就解決的困難的問題,就是這樣(我有簡化掉那篇的方法)
End
看起來像是這樣:
....
"text": "\u4e00\u6bb5\u5149\u5f71,\u4e00\u6bb5\u65c5\u884c\uff0e\n\n #\u4e58\u8457\u5149\u5f71\u53bb\u65c5\u884c\n #travel\n#light",
.....
(前後文就不特別放在這邊了,不重要)
那這種\u4e00\u6bb5... 取下來會是個QByteArray ,先把它們轉成QString
但還是一大串阿! 於是再用QString裡面的split -> QStringlist來承接。
所以現在可以切開變成u4e00,但這還是一個UTF8,所以我們需要再做調整
上網找了很多方法都沒有找到,但是找到了一篇 這裡 於是終於找到方法了!
解決方法其實很簡單:
不管怎麼弄,反正把\u (escape) 這兩個字元弄掉(QString::replace / QString:: remove)
剩下4e00
QString t1 = "4e00";
int Hex = t1.toInt(0, 16);
QString t2 = QChar(Hex);
你會發現t2 就轉成你要的字元了!
如此簡單就解決的困難的問題,就是這樣(我有簡化掉那篇的方法)
End
2016年8月17日 星期三
[VC++] Visual Studio 2005 搭配win7 相容性錯誤的解決方法
已知VS2005安裝在win7會有相容性問題,該怎麼解決網路上也有各種說法
但最後解決的辦法是看到stackoverflow上面的這篇文章:
http://stackoverflow.com/questions/1901492/windows-7-visual-studio-2005-compatibility
但最後解決的辦法是看到stackoverflow上面的這篇文章:
http://stackoverflow.com/questions/1901492/windows-7-visual-studio-2005-compatibility
I had a similar problem when I was installing Visual Studio 2005 Professional on a Windows 7 machine. But here is what I did to fix the problem:
Note: If you try and install #3 before #2, you will end up with a message that says : "The upgrade patch cannot be installed by the Windows Installer service because the program to be upgraded may be missing, or the upgrade patch may update a different version of the program. Verify that the program to be upgraded exists on your computer and that you have the correct upgrade patch."
Hope it helps.
看看這邊的回應,他是說先安裝VS2005 然後安裝team suite 最後才安裝SP1 update(順序不要搞混)
不然會出現已經安裝新版本之類的錯誤訊息
附上兩個連結 ,就這樣! end
|
2016年5月3日 星期二
[C++] WIA with VC++ 無法解析的外部符號 / 解決方法
在寫WIA的時候遇到了一個很棘手的問題,
大概錯誤訊息如:
error LNK2001: unresolved external symbol _CLSID_WiaDevMgr
error LNK2001: unresolved external symbol _IID_IWiaDevMgr
找了三天還是沒結果,後來才了解,解法:

就是這樣,在Project裡面的連結器(Linker)-->輸入(input)-->其它相依性輸入"WiaGuid.Lib"
問題解決! (記錄起來以免忘記)
END
大概錯誤訊息如:
error LNK2001: unresolved external symbol _CLSID_WiaDevMgr
error LNK2001: unresolved external symbol _IID_IWiaDevMgr
找了三天還是沒結果,後來才了解,解法:

就是這樣,在Project裡面的連結器(Linker)-->輸入(input)-->其它相依性輸入"WiaGuid.Lib"
問題解決! (記錄起來以免忘記)
END
2016年4月26日 星期二
[C++] Messagebox with int/long value , or text 如何顯示?
Debug時候,有時需要使用Messagebox,
但是要加入特定文字,或是變數該怎麼讓他顯示呢?
先從文字開始:
MessageBox(HWND hwnd, LPCWSTR lpText,LPCWSTR lpCation , UINT uType);
hwnd因為不需要特別設定 = 0
LPCWSTR lpText是Box內想說的話 ---> _T("我想說的話")
LPCWSTR lpCation是Box的標題 ---> _T("我的標題")
UINT uType 就是可以讓他選OK cancel等按鈕,這邊是填入MB_OK(可以自行調整)
我要填入ulong / int 怎麼辦??
CString msg;
msg.Format(_T("%d").變數名稱);
AfxMessageBox(msg);
這樣就可以囉!
END
但是要加入特定文字,或是變數該怎麼讓他顯示呢?
先從文字開始:
MessageBox(HWND hwnd, LPCWSTR lpText,LPCWSTR lpCation , UINT uType);
hwnd因為不需要特別設定 = 0
LPCWSTR lpText是Box內想說的話 ---> _T("我想說的話")
LPCWSTR lpCation是Box的標題 ---> _T("我的標題")
UINT uType 就是可以讓他選OK cancel等按鈕,這邊是填入MB_OK(可以自行調整)
我要填入ulong / int 怎麼辦??
CString msg;
msg.Format(_T("%d").變數名稱);
AfxMessageBox(msg);
這樣就可以囉!
END
訂閱:
文章 (Atom)