我想画线.
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
w.show();
QPainter painter(&w);
painter.setPen(QPen(Qt::black, 12, Qt::DashDotLine, Qt::RoundCap));
painter.drawLine(0, 0, 200, 200);
return a.exec();
}
Run Code Online (Sandbox Code Playgroud)
但窗户上没有任何画作.怎么了?
要安装boost我跑
b2 install optimization=speed variant=debug,release --layout=tagged --prefix=BOOST_DIR
Run Code Online (Sandbox Code Playgroud)
lib文件的名称如下
...
libboost_serialization-mt.lib
libboost_serialization-mt-gd.lib
...
Run Code Online (Sandbox Code Playgroud)
当项目链接时,我得到错误
链接:致命错误LNK1104:无法打开文件'libboost_serialization-vc140-mt-gd-1_62.lib'
此文件未在具有任何名称的项目设置中设置,仅设置此文件的目录.如果我将编译器和Boost版本添加到文件名,则项目成功链接.
当我安装新版本的Boost时,我可以让项目不需要Boost lib文件重命名吗?
还有vector的shared_ptr基类。
struct Base
{
virtual ~Base() = 0 {}
};
struct Derived1 : Base
{
};
struct Derived2 : Base
{
};
std::vector<std::shared_ptr<Base>> v;
v.push_back(std::make_shared<Base>(Derived1()));
v.push_back(std::make_shared<Base>(Derived2()));
Run Code Online (Sandbox Code Playgroud)
如何制作副本vector?
副本的指针必须指向新对象。
有一个函数可以获得period数组中每个长度间隔的最大值.
void f(const std::vector<double> &v, std::vector<double> &vv, size_t period)
{
vv.resize(v.size());
for (size_t i = period; i <= v.size(); ++i) {
vv[i - 1] = *std::max_element(v.begin() + i - period, v.begin() + i);
}
}
Run Code Online (Sandbox Code Playgroud)
如何通过性能优化此功能?
有QTableWidget。我需要发送带有行列和文本的 cellChanged 信号。我怎样才能做到这一点?
--
我已经将信号与插槽连接起来。我需要发送信号。
我需要自动化一些鼠标操作。
我需要做
mousemove1, lbuttondown1, wait1, mousemove1, lbuttonup1, wait1,
mousemove2, lbuttondown2, wait2, mousemove2, lbuttonup2, wait2,
...
这些动作必须针对屏幕坐标起作用。此时必须接受事件的窗口是顶部窗口。
有一个包含数据的文件。
例如
500 450 1000 500 300 2000
600 450 1000 600 300 5000
Run Code Online (Sandbox Code Playgroud)
我试图做什么
#include <fstream>
#include <vector>
#include <windows.h>
struct A
{
POINT point1;
unsigned sleep1;
POINT point2;
unsigned sleep2;
A() { point1.x = point1.y = sleep1 = point2.x = point2.y = sleep2 = 0; }
};
void f(const A &a)
{
mouse_event(MOUSEEVENTF_LEFTDOWN, a.point1.x, a.point1.y, 0, 0);
mouse_event(MOUSEEVENTF_MOVE, a.point1.x, a.point1.y, 0, 0); …Run Code Online (Sandbox Code Playgroud) 我试图使用一个简单的SSL示例.
这是一些代码:
void ShowCerts(SSL* ssl)
{
X509 *cert;
char *line;
cert = SSL_get_peer_certificate(ssl); /* get the server's certificate */
if ( cert != NULL )
{
printf("Server certificates:\n");
line = X509_NAME_oneline(X509_get_subject_name(cert), 0, 0);
printf("Subject: %s\n", line);
free(line); /* free the malloc'ed string */
line = X509_NAME_oneline(X509_get_issuer_name(cert), 0, 0);
printf("Issuer: %s\n", line);
free(line); /* free the malloc'ed string */
X509_free(cert); /* free the malloc'ed certificate copy */
}
else
printf("No certificates.\n");
}
Run Code Online (Sandbox Code Playgroud)
程序在free(line)代码行中崩溃.没有这些行,该程序可以正常运行而不会崩溃.如果我删除这些行,我担心在这种情况下,某些已分配的资源将不会被释放 - 我该怎么办?
谢谢.
我想在Android设备上运行最简单的Qt应用程序.有Android的AVD和真正的手机.对于他们两个我得到错误:
BUILD FAILED
/home/user1/dev/android-sdk-linux/tools/ant/build.xml:649: The following error occurred while executing this line:
/home/user1/dev/android-sdk-linux/tools/ant/build.xml:655: Execute failed: java.io.IOException: Cannot run program "/home/user1/workspace/build-Test11123-Android_for_armeabi_v7a_GCC_4_9_Qt_5_4_2-Debug/android-build/${aidl}": error=2, No such file or directory
at java.lang.ProcessBuilder.start(ProcessBuilder.java:1047)
at java.lang.Runtime.exec(Runtime.java:617)
at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:428)
at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:442)
at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:628)
at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:669)
at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:495)
at com.android.ant.AidlExecTask$AidlProcessor.process(AidlExecTask.java:102)
at com.android.ant.MultiFilesTask.processFiles(MultiFilesTask.java:131)
at com.android.ant.AidlExecTask.execute(AidlExecTask.java:203)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68)
at com.android.ant.IfElseTask.execute(IfElseTask.java:120)
at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:292)
at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
at org.apache.tools.ant.Task.perform(Task.java:348)
at org.apache.tools.ant.taskdefs.Sequential.execute(Sequential.java:68) …Run Code Online (Sandbox Code Playgroud) 我试图将我的Qt项目设置从Visual Studio 2013升级到2015。这几乎完成了,但是qtmaind.lib出现了一些错误。
1> qtmaind.lib(qtmain_winrt.obj):错误LNK2019:无法解析的外部符号 在函数_WinMain @ 16 1> qtmaind.lib(qtmain_winrt.obj)中引用的imp__RoInitialize @ 4:错误LNK2019:在函数“公共:__thiscall AppContainer :: AppContainer(void)”中引用的未解析的外部符号__imp__RoGetActivationFactory @ 12(?? 0AppContainer @@ QAE @ XZ)1> qtmaind.lib(qtmain_winrt.obj):错误LNK2019:在函数“ private:void __thiscall Microsoft :: WRL :: Wrappers :: HStringReference :: CreateReference(wchar_t const *,”中引用的未解析的外部符号_WindowsCreateStringReference @ 16 unsigned int,unsigned int)”(?CreateReference @ HStringReference @ Wrappers @ WRL @ Microsoft @@ AAEXPB_WII @ Z)1> qtmaind.lib(qtmain_winrt.obj):错误LNK2019:函数“ public:中引用的外部符号_WindowsDeleteString @ 4尚未解析无效__thiscall Microsoft :: WRL :: Wrappers :: HString ::Release(void)”(?Release @ HString @ Wrappers @ WRL @ Microsoft @@ QAEXXZ)1> qtmaind.lib(qtmain_winrt.obj):错误LNK2019:函数“ public:wchar_t const * __thiscall中引用的未解析的外部符号_WindowsGetStringRawBuffer …
c++ ×5
qt ×4
c++11 ×3
algorithm ×1
android ×1
boost ×1
c ×1
c++14 ×1
c++17 ×1
emit ×1
events ×1
free ×1
inheritance ×1
mouseevent ×1
openssl ×1
qpainter ×1
qt-creator ×1
qt5.6 ×1
qtablewidget ×1
shared-ptr ×1
string ×1
visual-c++ ×1
winapi ×1