Could you please help me with some modifications to my Qt6 code?
-
How can I fix the error 'C2039: 'data' is not a member of 'QWeakPointer<QCPAbstractPaintBuffer>'. that occurs when running it? plz help me
void QCPLayer::setMode(QCPLayer::LayerMode mode)
{
if (mMode != mode)
{
mMode = mode;
if (!mPaintBuffer.isNull())
mPaintBuffer.data()->setInvalidated();
}
} -
@Teemo-of-LOL Why is mPaintBuffer a QWeakPointer?
-
@jsulm Why is mPaintBuffer a QWeakPointer? I'm not sure about this part. This code was written previously, and it worked fine in Qt5. I tried searching on Google and made some modifications as follows. Is there anything suspicious in this?
void QCPLayer::setMode(QCPLayer::LayerMode mode)
{
if (mMode != mode)
{
mMode = mode;
if (!mPaintBuffer.isNull())
{
auto paintBuffer = mPaintBuffer.toStrongRef();
if (paintBuffer)
paintBuffer->setInvalidated();
}}
} -
@Teemo-of-LOL Should work, just try
-
@jsulm Now I only wonder where the strong ref on the weak pointer is - otherwise it's always a nullptr.
@Teemo-of-LOL: Please format you code with the code (
</>
) - tags so it's readable! -
@Christian-Ehrlicher I will use tags for reference.