gpt4 book ai didi

c++ - Q3DBars 仅在一个角上带有垂直标签,可能吗?

转载 作者:行者123 更新时间:2023-12-02 07:28:35 26 4
gpt4 key购买 nike

这是剧情

enter image description here

这是代码

.pro

QT      += core gui widgets datavisualization
TEMPLATE = app
SOURCES += main.cpp mainwindow.cpp
HEADERS += mainwindow.h

main.cpp

#include "mainwindow.cpp"
#include <QApplication>

int main(int argc, char *argv[]) {
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}

主窗口.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>

class MainWindow : public QMainWindow {
Q_OBJECT
public:
MainWindow(QWidget *parent = 0);
~MainWindow();
};

#endif // MAINWINDOW_H

主窗口.cpp

#include "mainwindow.h"
#include <QMainWindow>

#include <QtDataVisualization/Q3DBars>
using namespace QtDataVisualization;

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) {
resize(800,600);
Q3DBars *graph = new Q3DBars;
setCentralWidget(QWidget::createWindowContainer(graph));
graph->scene()->activeCamera()->setCameraPosition(30,30);
graph->activeTheme()->setGridLineColor(Qt::red);
}

MainWindow::~MainWindow(){}

我可以在一个角而不是两个角上放置垂直轴(值轴)的标签吗?

最佳答案

要添加自定义标签:

auto graph = new Q3DBars;
auto container = QWidget::createWindowContainer(graph);
setCentralWidget(container);

auto label = new QCustom3DLabel;
graph->addCustomItem(label);
label->setText("text");
label->setPosition(QVector3D(0,0.5,0));
label->setTextColor(Qt::red);
label->setScaling(QVector3D(1,1,1));

关于c++ - Q3DBars 仅在一个角上带有垂直标签,可能吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57644381/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com