Skip to content
  • QLabel with custom word wrap mode

    Unsolved General and Desktop qlabel wordwrap painteevent
    1
    0 Votes
    1 Posts
    15 Views
    No one has replied
  • Focus Rectangle paintEvent

    Unsolved General and Desktop qt5.12.x painteevent beginner
    8
    0 Votes
    8 Posts
    1k Views
    SGaistS
    Did you consider using a proxy style ?
  • What is the best way to do this?

    Solved Qt 6 qt5 c++11 painteevent
    4
    0 Votes
    4 Posts
    664 Views
    jsulmJ
    @Christina123 Use mousePressEvent, it provides the cursor position as parameter https://doc.qt.io/qt-5/qwidget.html#mousePressEvent
  • 0 Votes
    10 Posts
    9k Views
    Pablo J. RoginaP
    @Staslend if your issue is solved, please don't forget to mark your post as such! Thanks.
  • Changing colors of the QSlider

    Solved General and Desktop qslider painteevent color change
    2
    0 Votes
    2 Posts
    11k Views
    M
    I figured out the answer. I have to create a QSlider from scratch meaning not one created from the ui already. So, QSlider *slider = new MySlider(Qt::horizontal); ui->frameTestLayout->addWidget(slider); slider->setFocusPolicy(Qt::NoFocus); slider->setTickPosition(QSlider::TicksAbove); slider->setTickInterval(number);
  • 0 Votes
    3 Posts
    4k Views
    Mostafa WasatM
    @jsulm There're no calls to paintEvent() or update() inside updateGL() void OpenGLWidget::updateGL() { makeCurrent(); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); //LEQUAL glEnable(GL_CULL_FACE); glFrontFace(GL_CW); glLineWidth(1.0f); // glDisable(GL_DITHER); glEnable(GL_LINE_SMOOTH); glEnable(GL_MULTISAMPLE); glViewport(0,0,m_width , m_height); m_camera = m_cameraController.toMatrix(); QVector3D lightDirection; switch (m_currView) { case TopView: lightDirection = QVector3D(0.0,0.0,1.0); break; case BottomView: lightDirection = QVector3D(0.0,0.0,-1.0); break; case LeftView: lightDirection = QVector3D(-1.0,0.0,0.0); break; case RightView: lightDirection = QVector3D(1.0,0.0,0.0); break; case FrontView: lightDirection = QVector3D(0.0,-1.0,0.0); break; case BackView: lightDirection = QVector3D(0.0,1.0,0.0); break; } lightDirection.normalize(); QVector3D directionalColor = QVector3D(0.3,0.3,0.3); QVector3D ambientLight = QVector3D(0.5,0.5,0.5); m_world.setToIdentity(); m_world.translate(m_modelBox.getCenterPoint()); m_world.rotate(m_rotation); m_world.scale(1.0f, 1.0f, m_worldZScalar); m_world.translate(-m_modelBox.getCenterPoint()); QMatrix3x3 normalMatrix = m_world.normalMatrix(); if(geometries){ if(!m_drawWireFrame){ m_programGrid->bind(); //Set MVP Uniforms m_programGrid->setUniformValue(m_projMatrixLoc, m_proj); m_programGrid->setUniformValue(m_mvMatrixLoc, m_camera * m_world); m_programGrid->setUniformValue(m_normalMatrixLoc, normalMatrix); //Set Lighting Uniforms. m_programGrid->setUniformValue(m_lightDirectionLoc, lightDirection); m_programGrid->setUniformValue(m_directionalColorLoc, directionalColor); m_programGrid->setUniformValue(m_ambientColorLoc, ambientLight); //Draw Grid Geometry geometries->drawGeometry(m_programGrid); m_programGrid->release(); //Draw Border Lines if(m_showBorders){ m_programLines->bind(); m_programLines->setUniformValue(m_projMatrixLocLines, m_proj); m_programLines->setUniformValue(m_mvMatrixLocLines, m_camera * m_world); geometries->drawLines(m_programLines, QVector3D(0.0,0.0,0.0)); m_programLines->release(); } }else{ m_programLines->bind(); m_programLines->setUniformValue(m_projMatrixLocLines, m_proj); m_programLines->setUniformValue(m_mvMatrixLocLines, m_camera * m_world); geometries->drawLines(m_programLines, QVector3D(1.0,1.0,1.0)); m_programLines->release(); } } if(wellgeometries){ glLineWidth(4.0f); m_programLines->bind(); m_programLines->setUniformValue(m_projMatrixLocLines, m_proj); m_programLines->setUniformValue(m_mvMatrixLocLines, m_camera * m_world); wellgeometries->drawLines(m_programLines, QVector3D(1.0,0.0,0.0)); m_programLines->release(); } if(m_showCompass){ glDisable(GL_DEPTH_TEST); glViewport(0,0,100,100); m_world.setToIdentity(); m_world.translate(0,0,-5); m_world.rotate(m_cameraController.rotation().inverted()); m_world.rotate(m_rotation); QMatrix4x4 proj; // Set near plane, far plane , field of view const qreal zNear = 1.0f, zFar = 150.0f, fov = 45.0; proj.setToIdentity(); proj.perspective(fov, 1.0f, zNear, zFar); m_programGrid->bind(); m_programGrid->setUniformValue(m_projMatrixLoc, proj); m_programGrid->setUniformValue(m_mvMatrixLoc, m_world); m_programGrid->setUniformValue(m_normalMatrixLoc, normalMatrix); //Set Lighting Uniforms. m_programGrid->setUniformValue(m_lightDirectionLoc, lightDirection); m_programGrid->setUniformValue(m_directionalColorLoc, directionalColor); m_programGrid->setUniformValue(m_ambientColorLoc, ambientLight); compass->drawCompassGeometry(m_programGrid); m_programGrid->release(); } //doneCurrent(); }
  • 0 Votes
    7 Posts
    5k Views
    E
    @alex_malyu Well, it actually not. At least in this case (I don't know if this depends on your operating system, or on the type of widget or something like that) If I comment my update() call, paintEvent is never called, no matter how much I move the mouse over it.