When the dialog pops up, the chart series is drawn over the dialog.
-
wSetupBaseBckg::wSetupBaseBckg(wSpectrum_Settings* pSetUpWidget, QWidget* parent) : QDialog(parent), m_bClose(false), m_pWidget(pSetUpWidget) { ui.setupUi(this); this->setWindowFlags(Qt::FramelessWindowHint); this->setStyleSheet("QDialog{background-color: rgba(255, 255, 255, 100);}"); pSetUpWidget->setFixedSize(parent->size().width() * 75 / 100, parent->size().height() * 85 / 100); this->ui.verticalLayout->addWidget(pSetUpWidget); this->connect(pSetUpWidget, SIGNAL(UserDefineWidgetClose()), this, SLOT(WidgetClose())); this->connect(pSetUpWidget, SIGNAL(UserDefineWidgetApply()), this, SLOT(WidgetClose())); pSetUpWidget->Initailize(); } void wSpectrum::InitTableWidget() { m_pChart->setTitle(m_pSpectrumInfo->strMethodName); QList<QPair<QString, QList<qreal>>> lstTemp; QPair<QString, QList<qreal>> pairTemp; pairTemp.first = "WaveLength"; pairTemp.second = m_pSpectrumInfo->GetWaves(); lstTemp.append(pairTemp); if (!m_pDataModel) { m_pDataModel = new usrTableModel(lstTemp); this->ui.tableWidget->setModel(m_pDataModel); } else { m_pDataModel->InitData(); m_pDataModel->SetLowData(lstTemp); this->ui.tableWidget->reset(); } //this->ui.tableWidget->setModel(m_pDataModel); /*if (!m_pHeaderModel) m_pHeaderModel = new usrTableModel(lstTemp); else { m_pHeaderModel->InitData(); m_pHeaderModel->SetLowData(lstTemp); } this->ui.tableWidget->InitFrozenTableview(m_pHeaderModel);*/ // [축 설정] auto xAixs = std::minmax_element(lstTemp[0].second.begin(), lstTemp[0].second.end()); m_pChart->axisX()->setRange(*xAixs.first, *xAixs.second); m_pChart->axisY()->setRange(0, 5); QValueAxis* axisx = qobject_cast<QValueAxis*>(m_pChart->axes(Qt::Horizontal).first()); axisx->setTickCount(5); this->ui.tableWidget->update(); }
After drawing the chart, a dialog box pops up.
When popping up, the chart is drawn over the dialog.
I made the dialog background transparent, is that the cause? Other controls are well hidden.
However, only the line series of the chart is drawn.I found one more problem. Tablemodel's subclassing data and headData's events are not received.
So the data is not visible on the UI.QXYModelMapperPrivate::initializeXYFromModel "Invalid Y coordinate index in model mapper."
A message appears.There seems to be a problem initializing the chart.
There doesn't seem to be any problem with the code. -
Without a minimal, compilable example we can't say if it's a bug in Qt or on your side. I would guess it's on your side.
-
void wSpectrum::AddChartSeries(bool isData, usrTableModel* pModel) { QLineSeries* pSeries = new QLineSeries(m_pChart); //pSeries->setUseOpenGL(true); // 속도 향상 QVXYModelMapper* mapper = new QVXYModelMapper(this); mapper->setXColumn(0); mapper->setYColumn(pModel->GetColCount()-1); if(isData) mapper->setSeries(pSeries); mapper->setModel(pModel); m_pChart->addSeries(pSeries); m_pChart->createDefaultAxes(); // [축 재설정] { QValueAxis* axisx = qobject_cast<QValueAxis*>(m_pChart->axes(Qt::Horizontal).first()); axisx->setTickCount(5); m_pChart->axisX()->setTitleFont(cGlobalParam::gGetChartAxis(true)); m_pChart->axisX()->setTitleText("Wave Length"); m_pChart->axisX()->setTitleBrush(QBrush(QColor(76, 127, 185))); m_pChart->axisY()->setTitleFont(cGlobalParam::gGetChartAxis(true)); m_pChart->axisY()->setTitleText("Absorbance."); m_pChart->axisY()->setTitleBrush(QBrush(QColor(76, 127, 185))); } // [행의 마지막 위치로 이동] QModelIndex index = pModel->index(0, pModel->GetColCount()-1, QModelIndex()); this->ui.tableWidget->scrollTo(index, QAbstractItemView::PositionAtTop); } void wSpectrum::BtnMeasure() { QPair<QString, QList<qreal>> pairTemp2; pairTemp2.first = QString("D_%1").arg(m_pDataModel->GetInputData().count()); for (int i = 0; i < this->m_pSpectrumInfo->GetDataCount()+1; i++) { qreal qRan1 = QRandomGenerator::global()->bounded(0, 10); qreal qRan2 = QRandomGenerator::global()->generateDouble(); pairTemp2.second.append(qRan1 + qRan2); } m_pDataModel->AppendData(pairTemp2); AddChartSeries(true, m_pDataModel); //this->update(); }
I am connecting tables and charts with Abstractmodel. It draws a series whenever data comes in, but the setUseOpenGL option seems to be the cause. Please understand that we cannot upload the full source.
-
pSeries->setUseOpenGL(true); If I disable the function, it works fine.
The problem with this is that even if you delete all the series in the chart, it remains on the screen. But when I switch to another screen with the mouse, it is cleared.This is a bug.
-
If you can't provide a minimal, compilable example we can't help here. I doubt it's a bug in Qt but on your side. If you think it's a bug, write a bug report but even there you need a minimal, compilable examle to get your problem fixed...
-
https://github.com/HaonPAPA/MyRepository/blob/main/linechart.7z
I have created an example. A dialog box pops up after creating a series by clicking the Add series button.
A blue widget is floating in the dialog. It is drawn over the widget. -
It's the combination of Qt::FramelessWindowHint and OpenGl. You should create a bug report with your testcase.
-
Are you saying it's a bug?
-
Yes - as I told you create a bug report, but why do you need such a dialog on top?
-
I am trying to open an option window. However, as a form of style, I tried to lower the alpha value around it to draw more attention to the options window.
The method I have implemented may not be the normal method.
If there is a better way please suggest -
What's wrong with a simple QDialog?
-
This is the UI I wanted. -
This is a simple QMessageBox. Why so much work? Why must it be frameless?
-
The program we are developing is user UI-oriented, so we have to pay a lot of attention to the little things.
answer my question
What I want is to blur the background behind it. It could be done very simply in C# too.
Is there a better way than the way I did? -
I don't know - if you've a commercial license then ask TQtC to fix it. Otherwise find a workaround.