Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Q3DScatter is too small in QWidget

Q3DScatter is too small in QWidget

Scheduled Pinned Locked Moved Solved General and Desktop
2 Posts 1 Posters 226 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    horseface
    wrote on last edited by
    #1

    Hi all, I am trying to create a Q3DScatter class that I can use in Qt Designer by promoting a QGraphicalView widget.
    While I can display something, the size of the Q3DScatter is always very small.
    Below is the example code I use to demo the problem:

    This is the class I will promote my GraphicalView widget to:

    #include <QtDataVisualization/q3dscatter.h>
    #include <QtDataVisualization/qabstract3dseries.h>
    #include <QtDataVisualization/q3dscatter.h>
    #include <QtWidgets/QWidget>
    #include <QtGui/QScreen>
    #include <QtGui/QSurfaceFormat>
    using namespace QtDataVisualization;
    class Graph3d: public QWidget
    {
    private:
    
        Q3DScatter *scatter;
        QScatter3DSeries *series;
        QWindow *window;
    public:
        Graph3d(QWidget *parent);
        ~Graph3d();
        
    };
    
    Graph3d::Graph3d(QWidget *parent)
    {
        this->setParent(parent);
        this->scatter = new Q3DScatter();
        
        this->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
        this->setFocusPolicy(Qt::StrongFocus);
    
        this->scatter->setMinimumSize(QSize(1000,1000));
        
        this->createWindowContainer(this->scatter,this);
        scatter->setFlags(scatter->flags() ^ Qt::FramelessWindowHint);
        this->series = new QScatter3DSeries;
        QScatterDataArray data;
        data << QVector3D(0.5f, 0.5f, 0.5f) << QVector3D(-0.3f, -0.5f, -0.4f) << QVector3D(0.0f, -0.3f, 0.2f)
        << QVector3D(1.5f, 0.5f, 0.5f) << QVector3D(-1.3f, -0.5f, -0.4f) << QVector3D(1.0f, -1.3f, 1.2f)
        << QVector3D(0.5f, 0.5f, 4.5f) << QVector3D(-0.3f, -3.5f, -0.4f) << QVector3D(0.0f, -0.3f, 2.2f)
        << QVector3D(0.5f, 0.5f, 5.5f) << QVector3D(-3.3f, -0.5f, -0.4f) << QVector3D(0.0f, -3.3f, 0.2f)
        << QVector3D(1.5f, 10.5f, 0.5f) << QVector3D(-5.3f, -0.5f, -0.4f) << QVector3D(4.0f, -0.3f, 0.2f);
        this->series->dataProxy()->addItems(data);
        scatter->addSeries(series);
        
    }
    
    Graph3d::~Graph3d()
    {
    }
    

    And here is the main

    #include <QtWidgets/QApplication>
    #include <QtDataVisualization/q3dscatter.h>
    #include <QtDataVisualization/qabstract3dseries.h>
    #include <QtDataVisualization/q3dscatter.h>
    #include <QtWidgets/QWidget>
    
    using namespace QtDataVisualization;
    #include "Graph3d.h"
    #include <QtWidgets/QHBoxLayout>
    int main(int argc, char **argv)
    {
        QApplication app(argc,argv);
        QWidget *widget = new QWidget();
        QHBoxLayout *layout = new QHBoxLayout(widget);
        Graph3d *graph_3d = new Graph3d(widget);
        layout->addWidget(graph_3d);
    
        widget->setMinimumSize(QSize(1000,1000));
    
        widget->show();
    
    
        return app.exec();
    }
    

    No matter where I set the size, it does not affect the size of the scatter plot. What did I do wrong?

    1 Reply Last reply
    0
    • H Offline
      H Offline
      horseface
      wrote on last edited by
      #2

      After few days of trying, I realized

      this->createWindowContainer(this->scatter,this);
      

      the return QWidget* will not be assigned to the base class, thus, not the correct method.
      Perhaps it will be much easier to directly add the 3D scatter to a widget instead of promoting QGraphicalView.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved