ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  QViewPortControl and Layouts
Posted by Thomas on Jun-29-2022 21:20
Hello,

new to Qt, I'm evaluating your ChartDirector library. In your example xyzoomscroll.cpp you are using the Viewport Control:

m_ViewPortControl = new QViewPortControl(frame);
m_ViewPortControl->setGeometry(QRect(5, 334, 112, 112));

This places the Viewport Control on an absolute position within the dialog.

What has to be done, if one wants to have the Viewport Control embedded in QVBoxLayout, QHBoxLayout or QGridLayout?

Best regards and thank you in advance
Thomas

  Re: QViewPortControl and Layouts
Posted by Peter Kwan on Jun-30-2022 17:53
Hi Thomas,

I suppose you can just create the QVBoxLayout as usual, and put the controls in it.

For example, in the QViewPortControl sample code, the left size is occupied by some buttons in a frame. We can put a frame on the right side, and associate it with the QVBoxLayout, then put the QChartViewer and QViewPortControl in that layout.


    // This is the frame on the right side.
    QFrame *frame2 = new QFrame(this);
    frame2->setGeometry(128, 4, 650, 560);

    // This is the layout
    QVBoxLayout *layout = new QVBoxLayout();
    layout->setSpacing(0);
    layout->setMargin(0);
    frame2->setLayout(layout);

    // Add the QChartViewer to the layout
    m_ChartViewer = new QChartViewer(this);
    layout->addWidget(m_ChartViewer,0, Qt::AlignTop);
    connect(m_ChartViewer, SIGNAL(viewPortChanged()), SLOT(onViewPortChanged()));
    connect(m_ChartViewer, SIGNAL(mouseMovePlotArea(QMouseEvent*)),
        SLOT(onMouseMovePlotArea(QMouseEvent*)));

    // Add the QViewPortControlto the layout
    m_ViewPortControl = new QViewPortControl(this);
    layout->addWidget(m_ViewPortControl,0, Qt::AlignTop);
    ..........


Best Regards
Peter Kwan