我需要构建简单的服务器
该计划的一些重要方面:
基本上我的问题是:
我应该用什么编程语言呢?
Java?
C++?
我如何嵌入我的应用程序使用的图标或图像,我不知道在我的应用程序根目录中保存图像目录,是否有任何有效的方法?
我正在寻找免费且简单的GUI框架,让我创建没有依赖的单个exe(如.Net框架),而不是GPL
作为旁注..我使用Qt和它的伟大,但我必须是LGPL使用它,这意味着很多胖dll.还有其他选择吗?
ps Dropbox客户端是如何制作的?我知道它的python但它们是如何构建它的?py2exe?
当我在我的代码中声明类似的东西时意味着什么:Foo*foo(); 它给我带来了什么好处?如你所见,我不是简单的指针变量.如果我在所有方法的c ++源代码中声明它是什么意思,例如:
// Test cpp class
.
#include "Foo.h"
Foo * foo();
Test::Test() {}
Test::GetFooMethods()
{
foo()->someMethod();
}
…
…
Run Code Online (Sandbox Code Playgroud) 我有一个基本上处理日志的单例类.我在代码中调用它的每个地方,我都要输入:
LogClass::GetInstance()->WriteToLog("text");
Run Code Online (Sandbox Code Playgroud)
如何缩短此调用以便我可以只键入WriteToLog("text")并调用单例对象上的函数?
我必须说我是win32 c ++编程的新手,所以我遇到的问题是
某些代码在多字节字符集中编译而不是在Unicode字符集中编译.
我的代码怎么能同时支持?
例如,此NOT仅在Unicode中编译多字节,仅在MultiByte中编译注释向量:
//vector<char> str2(FullPathToExe.begin(), FullPathToExe.end());
vector<wchar_t> str2(FullPathToExe.begin(), FullPathToExe.end());
str2.push_back('\0');
if (!CreateProcess(NULL,
&str2[0],
NULL,
NULL,
TRUE,
0,
NULL,
NULL,
&si,
&pi))
Run Code Online (Sandbox Code Playgroud) 我有情况,我QDialog从main.cpp文件打开窗口,然后我等待exec()方法返回基于成功或失败的QDialog.像这样 :
int main( ... ) {
LoginDialog *loginDlg = new LoginDlg;
if( loginDlg->exec() != Qt:;Accepted ) {
return 0;
}
//check the login Info
delete loginDlg;
MainWindow w;
w.show()
return app.exec();
}
Run Code Online (Sandbox Code Playgroud)
从Qt示例(地址簿)我看到我可以使用accept()和reject()插槽.问题是我喜欢基于某些功能流关闭的窗口,而不是ok/close按钮.如何从功能中触发这些插槽?.
我有QTimer的线程,我喜欢它能够动态更改其执行间隔而无需重新启动应用程序:这是QThread运行方法中的代码:
void myThread::run()
{
QTimer timer1;
connect(&timer1, SIGNAL(timeout()),
this,SLOT(fire(),Qt::DirectConnection));
qDebug() << "A::run() worker thread -- currentThread:" << currentThread();
timer1.start(1000);
QThread::exec();;
}
Run Code Online (Sandbox Code Playgroud) 在阅读了一些例子后,我仍然遗漏了一些东西.我有Qtreeview用于视图和QStandardItemModel用于数据接口,也使用QSortFilterProxyModel子类但我不知道它是否相关.这是我的逻辑:首先我用QWidget作为父模型创建模型:
QStandardItemModel m_model = new QStandardItemModel(0,4,parent);
then setSourceModel(m_model) for the widget
Run Code Online (Sandbox Code Playgroud)
使用QSortFilterProxyModel设置树视图.这样的事情:
GroupProxyModel = new GroupSortFilterProxyModel;
GroupProxyModel->setDynamicSortFilter(true);
setSourceModel(createSubjectModel(parent));
ui.treeView_mainwindow->setModel(GroupProxyModel);
ui.treeView_mainwindow->setSortingEnabled(true);
Run Code Online (Sandbox Code Playgroud)
然后我填写第一行,如下所示:
QList<QStandardItem *> items;
items.insert(0,new QStandardItem("Test 0"));
items.at(0)->setEditable(false);
m_model->insertRow(0,items);
Run Code Online (Sandbox Code Playgroud)
到目前为止,每件事情都很好,我看到了数据行.但是,当我想像这样添加子行:
QModelIndex parentQModelIndex = m_model->item(0,0)->index();
m_model->insertRows(0,1,parentQModelIndex);
m_model->insertColumns(0,1,parentQModelIndex);
QModelIndex indexB = m_model->index(0, 0, parentQModelIndex);
m_model->setData(indexB,"Child test",Qt::DisplayRole);
Run Code Online (Sandbox Code Playgroud)
但我没有看到孩子,为什么?
我有一个C++应用程序,我正在设置一个简单的文本字符串,std::string如下所示:
string foo = "my test string";
Run Code Online (Sandbox Code Playgroud)
但是当我在调试器中看到它时,我得到了这个:
{_Buf=0x09d55c50 "my test string" _Ptr=0x74736e69 "‹M?QhDqrtV?‹?‹V?P?‹U?RhDqrtP?‹?…?u?u‹M??uƒ?$?Fo" }
Run Code Online (Sandbox Code Playgroud)
或者在另一个字符串中我得到了这个:
{_Buf=0x09d55c70 "some other string" _Ptr=0x7372614c <Bad Ptr> }
Run Code Online (Sandbox Code Playgroud)
我正在将它输入到Visual Studio Express 2008中,当然我发现它在一些其他的lib之后,期望这个字符串不断变得异常.
当我把它改成foo="";一切都很好.
lib api的功能如下所示:
connect(const std::string& hostName, const std::string& userName, const std::string& password)
Run Code Online (Sandbox Code Playgroud)
(MySQL C++连接器)
我的问题是这是什么_Ptr,更重要的是为什么我得到例外?
更新
确定它真的很奇怪,但导致我异常的事情是字符串的长度只有当我设置15个字符长字符串它是好的但如果我设置更长的字符串异常是throwen.即时通讯使用visual studio 2008 express 32位