我有点坚持使用最大可用精度存储数字:
double tmp = 569.232306826889043804840184748172760009765625L;
Run Code Online (Sandbox Code Playgroud)
我正试图在屏幕上打印它:
printf("%0.52f\n", tmp);
Run Code Online (Sandbox Code Playgroud)
这就是我所拥有的:
569.2323068268890400000000000000000000000000000000000000
这是我能达到的最高精度吗?
PS我正在使用Visual Studio 2008
我只是在写一个小应用程序,其中我的功能看起来像:
QString askForDir()
{
return QFileDialog::getExistingDirectory(this, "Choose directory", QString(""));
}
Run Code Online (Sandbox Code Playgroud)
因为我已经添加了这个函数,所以我提到在使用这个函数(askForDir())之后内存分配变得非常奇怪.
我使用OS X Instruments应用程序来调试需求,所以这就是我所拥有的:
峰值是askForDir()函数运作的时刻,我的意思是构建目录树.
在这些峰值之间有空间没有发生任何事情,我的意思是app什么都不做,只是等待用户的其他动作.
正如您所看到的,内存分配正在增长.如果你想要数字:
at 30sec - 91 Mb
at 50sec - 113 Mb
at 1m15sec - 135 Mb
Run Code Online (Sandbox Code Playgroud)
每次它都在增长 22 Mb
我试图探索它并将askForDir()功能更改为smth,如下所示:
QString askForDir()
{
return "/Users/username/Desktop";
}
Run Code Online (Sandbox Code Playgroud)
我上面所说的一切都消失了.所以,我得出结论,问题出在QFileDialog中.
这是我正在使用的:
还有其他人有同样的"问题"吗?
我有读取一些文档SWIG文档(与C ++代码),但不能找出是否有可能genereate Python扩展模块的情况下,我已编译的DLL(没有提供源代码)和头文件的所有功能在宣布dll。
如果有人遇到同样的问题并解决了它,你能提供一些有用的例子吗?
提前致谢。
我有非常具体的情况.我想QAction进入QToolbar并达到以下行为:
QAction可用图标查看.QDialog应该出现在屏幕上而不是QMenu像一个Now I'm a bit confused with implementing all this things together.
For now I've created QAction added it to toolbar and also created an empty QMenubecause I didn't get the idea of how to add the "dropdown" arrow another way.
So, I also connected my slot to QMenu aboutToShow() signal and now, I can create my dialog and exec() it just before QMenu shows. But here's …
我想弄清楚是否有可能在std::unique_ptr内部的帮助下编写一个安全的拷贝构造函数.
这是我的代码:
#include <iostream>
#include <memory>
class A {
public:
A():_a(10){
std::cerr << "A() constructor" << std::endl;
}
A(const A& tmp){
_a = tmp._a;
std::cerr << "A() copy constructor" << std::endl;
}
~A(){
std::cerr << "~A()" << std::endl;
}
int _a;
};
class B {
public:
B():_b(5){
std::cerr << "B() constructor" << std::endl;
}
B(const B& tmp){
std::cerr << "B() copy constructor" << std::endl;
throw std::exception("exc");
}
~B(){
std::cerr << "~B()" << std::endl;
}
int _b;
};
class …Run Code Online (Sandbox Code Playgroud) 问题是我有150 000多个节点,200 000+(可能有多达1 000 000甚至更多),所有节点都被写入数据库.现在我想创建一个可以打开路由访问权限的普通图表.所以,我需要使用现有数据库中的数据来组合它.我们的想法是构建这个巨大的图形,将其分成小块并写入DB BLOBS进行存储.我尝试以递归方式构建它,但在我看来,堆栈无法存储如此多的数据,并且我的算法一直打破分配错误.所以,现在我对一种允许我构建这个图的方式感到困惑.我正在考虑某种迭代方法,但主要问题是架构,我的意思是我将用于存储节点和弧的结构.当我看到这个解决方案时,应该是这样的史密斯:
struct Graph
{
unsigned int nodesAmount;
unsigned int arcsAmount;
vector<Node*> NodeArr; //Some kind of container to store all existing Nodes
}
struct Node
{
unsigned int id;
int dimension; //how many arcs use this node
vector<Arcs*> ArcArr;
}
struct Arcs
{
unsigned int id;
double cost;
Node* Node_from;
Node* Node_to;
}
Run Code Online (Sandbox Code Playgroud)
我阅读了很多关于存储图形方法的文章,但没有找到真正好的解决方案.任何想法我都会很高兴.谢谢
我QTableWidget里面有一些专栏.
由于我的需要,我QComboBox在一些列中设置并填充必要的数据.
void settingsDialog::onAddFieldButtonClicked()
{
fieldsTable->setRowCount(++rowCount);
combo = new QComboBox();
combo->addItem(QString("Choose from list..."));
foreach( int height, heightsAvailable)
combo->addItem(QString("%1").arg(height));
fieldsTable->setCellWidget(rowCount-1, 3, combo);
// etc for other columns ...
}
Run Code Online (Sandbox Code Playgroud)
问题是如何更改来自这个组合框的信号?
我想知道row和col更改小部件(组合框)和已设置的值.
我已经尝试过Qt docs中提到的所有可用信号QTableWidget,但它们仅在单元格内部没有小部件的情况下工作.
是否有一种简单的Qt方式来获得我需要的东西?
我有一个特定的目标:画一个路网.所以我有一些点(x,y),我想连接它们(使用drawLine函数).因为他们的数量(大约2-3百万)我需要在另一个线程中做,所以有一个问题我应该怎么做?我有一个特殊的绘图区域 - QLabel.我试图通过主线程中的QPixmap来做到这一切都很好,但当我尝试通过另一个线程中的信号/插槽来做它没有图像出现:(
实际上,当我将坐标转换为GUI坐标时,它们变为小数,因此我不知道如何绘制它们,因为drawLine函数具有整数参数:(int x1,int y1,int x2,int y2).
这就是我创建另一个线程的方式(我只需要运行一个函数,所以这是我认为最好的方法)
QtConcurrent::run(this,&MainWindow::parseXML)
希望你会帮助我,因为我会变得疯狂%)
PS我读过多线程绘图不支持QPixmap.所以现在我不知道该怎么做.
QPainter can be used in a thread to paint onto QImage, QPrinter, and QPicture paint devices. Painting onto QPixmaps and QWidgets is not supported. On Mac OS X the automatic progress dialog will not be displayed if you are printing from outside the GUI thread.
c++ ×5
qt ×4
architecture ×1
c ×1
c++11 ×1
constructor ×1
database ×1
dll ×1
drawing2d ×1
graph ×1
memory ×1
memory-leaks ×1
python ×1
qdialog ×1
qfiledialog ×1
qmenu ×1
qpixmap ×1
qtablewidget ×1
signals ×1
swig ×1
types ×1
wrapper ×1