我现在使用Qwt已经两年了.我喜欢它的面向对象的类,这使得很容易适应这些图和功能.如今,QCustomPlot正变得越来越受欢迎,并与Qwt竞争.当然我确实比较了API.但是,我对两个图书馆的有经验的用户的证词感兴趣.什么方便?什么不是?有任何陷阱吗?
在类似于QCustomPlot财务演示的项目中,我想将QCPItemRect不仅绘制到图表区域,还绘制到图表下方的区域.
有
QCPAxisRect * xRect = new QCPAxisRect( this->ui.customPlot )
...
this->ui.customPlot->plotLayout()->addElement(1, 0, xRect);
Run Code Online (Sandbox Code Playgroud)
我想添加QCPItemRect之类的
QCPItemRect * xItem = new QCPItemRect( this->ui.customPlot );
xItem -> setPen ( QPen ( Qt::black ));
xItem -> bottomRight ->setAxisRect( this->xRect );
xItem -> topLeft ->setAxisRect( this->xRect );
xItem -> bottomRight ->setCoords(x - 2.0, y - 2.0);
xItem -> topLeft ->setCoords(x + 2.0, y + 2.0);
this->ui.customPlot->addItem( xItem );
Run Code Online (Sandbox Code Playgroud)
然而,矩形仍然被绘制this->ui.customPlot而不是this->xRect.为什么?
Daniel,非常感谢任何帮助
更新 我自己找到了答案的一部分,缺少一行代码
xItem -> setClipAxisRect( xRect …Run Code Online (Sandbox Code Playgroud) 我试图QCustomPlot在我的线条样式中显示不同点的绘图值lsLine.我知道我可以设置一个鼠标悬停在信号上QCustomPlot但不会真正有用,因为我只需要在鼠标悬停在绘制的线上时得到通知.我的问题是有没有办法找出鼠标是否在我的散点上.是否有可以连接的信号,当鼠标在散点上时会告诉我?
我正试图找到一种方法来显示数学符号,如\ theta,\ phi,\ dot {\ theta},...等等.我找不到在我的情节中显示这些字母的方法.是否qcustomplot支持数学符号?我尝试了以下几行,但很少有字母出现,但其余的则没有.
ui->customPlot1->graph(0)->setName(QString("\u0024"));
我有一个Qt Quick项目,我刚刚添加了一些源文件.在尝试构建时,我收到错误消息:
QWidget: Cannot create a QWidget without QApplication
Run Code Online (Sandbox Code Playgroud)
由于我有一个Qt Quick项目,我使用QGuiApplication.QApplication是QGuiApplication的子类.如何使QApplication可用于新添加的源?或者当一个人拥有Qt Quick和QWidget时如何解决它?
源文件是显示图形的QCustomPlot库.
编辑:
main.cpp中:
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
QtQuick2ApplicationViewer viewer;
//Register C++ classes with QML
qmlRegisterType<Bluetooth>("Bluetooth", 1, 0, "Bluetooth");
//Set start QML file
viewer.setMainQmlFile(QStringLiteral("qml/test/main.qml"));
//New Code:
// generate some data:
QWidget widget;
QCustomPlot * customPlot = new QCustomPlot(&widget);
QVector<double> x(101), y(101); // initialize with entries 0..100
for (int i=0; i<101; ++i)
{
x[i] = i/50.0 - 1; // x goes from -1 to 1 …Run Code Online (Sandbox Code Playgroud) 我正在寻找一些关于如何实现与a一起使用的自定义分配器的指针std::map.我有兴趣用数百万个条目填充地图而不为容器中的每个元素分配(这是此容器的默认值).这样做的原因是将数据传递给使用地图存储图表样本的第三方库(QCustomPlot),并且在绘制大型时间序列时我感觉性能受到影响.
如果std::map事先已知大小,是否可以通过一次分配来完成此操作?
编辑:节点将按升序输入容器.
在隐藏网格的同时,有没有办法在QCustomPlot中显示zeroline?我试过用以下行隐藏网格:
ui->customPlot->xAxis->grid()->setVisible(false);
ui->customPlot->yAxis->grid()->setVisible(false);
Run Code Online (Sandbox Code Playgroud)
但这也隐藏了zerolines.我需要保持zerolines可见.
我正在使用QCustomPlotQt来绘制视频序列的各个方面.
我想定义图表的背景,以便定义我的特定区域yAxis.我的图是这样的:

我想在我的定义间隔yAxis得到这样的东西:

最后一张图片属于一个名为PEAT的程序,用于分析可触发癫痫发作的视频.我指的是他们沿着区域定义区域的方式yAxis.
有什么建议?
我正在尝试在我的控制台应用程序中使用 QCustomPlot。我首先为它创建了一个适合我用途的简单包装器。包装器应该是但是,每次我尝试显示窗口时,我都会收到 std::bad_alloc 错误。
这是我的代码,我在以下位置创建了一个包装类Plot.hpp:
class Plot
{
private:
std::string name;
QApplication* app;
QMainWindow* window;
QCustomPlot* plotWidget;
public:
Plot(std::string& name);
// OTHER METHODS
void showPlot();
};
Run Code Online (Sandbox Code Playgroud)
在我的Plot.cpp文件中,我有以下内容:
Plot::Plot(std::string& name) : name(name)
{
char *gui_argv[] = {(char*)(name.c_str()), NULL};
int gui_argc = sizeof(gui_argv) / sizeof(char*) - 1;
app = new QApplication(gui_argc, gui_argv);
window = new QMainWindow();
// Add plot Widget
plotWidget = new QCustomPlot(window);
window->setCentralWidget(plotWidget);
plotWidget->plotLayout()->clear();
}
// OTHER METHODS
void Plot::showPlot()
{
// Run the GUI
window->show(); …Run Code Online (Sandbox Code Playgroud)