Navigation

    Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Search
    • Unsolved
    1. Home
    2. Tags
    3. qlabel
    Log in to post

    • SOLVED Selecting a label from a list of labels using a rubber band does not work properly
      General and Desktop • qlabel selection qrubberband • • Stavros Vaionitis  

      4
      0
      Votes
      4
      Posts
      141
      Views

      Hi all, I finally managed to find out what was the problem. The fix is the following @@ -26,7 +26,7 @@ void MainWindow::mousePressEvent(QMouseEvent* event) // If a QLabel contains the mouse pointer, then this is the QLabel that was selected QList<QLabel*> qLabelList = ui->videoStreamsFrame->findChildren<QLabel*>(); foreach(QLabel *l, qLabelList) { - QPoint mappedMousePosition = l->mapFromGlobal(mousePosition); + QPoint mappedMousePosition = l->mapToParent(l->mapFromGlobal(mousePosition)); if (l->geometry().contains(mappedMousePosition)) { rubberBand = new QRubberBand(QRubberBand::Rectangle, l); rubberBand->setGeometry(l->rect()); So, the mapFromGlobal() is translating the global coordinates to widget coordinates and the geometry(), where we use in order to check if the mouse coordinates are contained in the label, has the coordinates relative to the parent widget. So, we need to map the mouse coordinates to the parent widget, hence the function mapToParent(). Kind regards, Stavros
    • UNSOLVED How to refer to labels created in a for loop?
      General and Desktop • qlabel loop object name • • BigBen  

      6
      0
      Votes
      6
      Posts
      160
      Views

      @BigBen Store them in a container yourself as you create them: QList<QLabel *> labels; for (int i = 0; i < 10; i++) { QLabel *label = new QLabel; someLayout->addWidget(label); labels.append(label); } Assign them an objectName for future reference to recall an individual one: QList<QLabel *> labels; for (int i = 0; i < 10; i++) { QLabel *label = new QLabel; label->setObjectName(QString("label_%1").arg(i)); someLayout->addWidget(label); } QLabel *label_2 = someParentWidget->findChild<QLabel *>("label_2"); Collect them all via findChildren(): QList<QLabel *> labels = someParentWidget->findChildren<QLabel *>();
    • SOLVED Resize window screen when all tabs of tabWidget closed
      General and Desktop • layout qlabel resize qtabwidget • • BigBen  

      5
      0
      Votes
      5
      Posts
      123
      Views

      I see. Thank you.
    • UNSOLVED Drag and Drop Implementation
      General and Desktop • qlabel drag and drop icons • • Wiki_Wut  

      9
      0
      Votes
      9
      Posts
      219
      Views

      Awesome, I will check that out, thank you very much!
    • SOLVED How can I place a qlabel over qwidget placed in a window container?
      General and Desktop • qwidget qlabel window • • new.qt_user-2022  

      6
      0
      Votes
      6
      Posts
      478
      Views

      @new-qt_user-2022 All the best! Feel free to post new questions if you'd like further help.
    • SOLVED Cout in a loop for QLabel Widgets
      General and Desktop • qlabel qmap loop cout label • • Swati777999  

      9
      0
      Votes
      9
      Posts
      343
      Views

      @jsulm said in Cout in a loop for QLabel Widgets: @Swati777999 Names[ii] = new QLabel(QString("Name %1").arg(ii)); Works perfectly! Thanks.
    • UNSOLVED How do I make a QLabel Blink?
      General and Desktop • windows 10 qlabel qtimer mainwindow qt6.1.2 • • DougyDrumz2  

      5
      0
      Votes
      5
      Posts
      370
      Views

      @DougyDrumz2 said in How do I make a QLabel Blink?: The consensus is evidently to l hide and show a QLabel Not my "consensus :) So far as I am aware, hiding can cause different layout redraw in at least some circumstances. I retain visibility but toggle foreground color to QColor(Qt::transparent) or toggle alpha color value between 255 (opaque) and 0 (transparent) on palette QPalette::setColor(QPalette::Text, colour). Also, creating multiple QTimer::singleShot()s doesn't scale very well if you want to change the number of flashes or the interval between. Or of you have multiple labels to blink and you'd like them all to be "in sync". I use one regular repeating QTimer with a "countdown" and cancellation when it reaches 0. Up to you on both of these.
    • UNSOLVED QLabel image load
      General and Desktop • c++ qlabel qscrollarea show images • • Sai Raul  

      8
      0
      Votes
      8
      Posts
      311
      Views

      @Sai-Raul ok. but Qlabels only likes pixmaps.
    • UNSOLVED Video recording
      General and Desktop • qlabel camera videocapture camera live video recording • • Sai Raul  

      2
      0
      Votes
      2
      Posts
      161
      Views

      @Sai-Raul Start here: https://doc.qt.io/qt-5/videooverview.html
    • UNSOLVED Image showing in QLabel
      General and Desktop • qlabel qpixmap • • Sai Raul  

      4
      0
      Votes
      4
      Posts
      156
      Views

      @Sai-Raul said in Image showing in QLabel: Already tried that And what was the outcome? Please update your code accordingly.
    • UNSOLVED QLabels have same width regardless of text?
      General and Desktop • widget layout qlabel • • hsetlik  

      9
      0
      Votes
      9
      Posts
      311
      Views

      @eyllanesc Oh I see, it's working now. Thank you!
    • SOLVED How to get required height for a QLabel without showing the label?
      General and Desktop • qt for python qlabel qt for windows • • ThePyGuy  

      10
      1
      Votes
      10
      Posts
      1501
      Views

      @J-Hilk Thanks for the response, I'll look into that stackoverlfow thread
    • SOLVED Auto line-break with QLabel within QTableWidget
      General and Desktop • qtablewidget qlabel qt 5 wordwrap • • silverfox  

      3
      0
      Votes
      3
      Posts
      571
      Views

      @ChrisW67 Thanks! It work like a charm. For the reason to why I was using QLabel, well I'm mostly testing for stuffs. I'll switch it up later.
    • UNSOLVED QLabel::setText() not responding properly
      General and Desktop • qlabel settext • • surajj4837  

      7
      0
      Votes
      7
      Posts
      388
      Views

      @JonB Thanks, this is new information for me. Actually the "QVTKWidget" was sufficing my problem to display point cloud data. For now it is working properly because I m using VTK 7.0. It seems post VTK 8.0, the QVTKOpenglWidget needs to be used.
    • UNSOLVED How to Create Qt Custom Designer Widget
      General and Desktop • qlabel custom widget designer plugin • • Glenomat  

      1
      0
      Votes
      1
      Posts
      126
      Views

      No one has replied

    • SOLVED Using QTimer::singleShot correctly for updating messages on GUI
      General and Desktop • qtcreator qlabel qtimer • • TUStudi  

      8
      0
      Votes
      8
      Posts
      818
      Views

      @TUStudi said: I actually have 6 QLabels, so I now have 6 timer and so on Derive a class from QLabel and add that functionality to it. Don't write the same code 6 times! My QLabels have the sizePolicy horizontal: preferred and vertical: fixed and a vertical length of 20. When a text is displayed, the QLabel expands so that the elements above the QLabel are also moved upwards and after the text disappears, they go back to their initial place. Fixed size policy means that widget uses its sizeHint() as the size. If you change the text the size hint also changes, so label grows/shrinks.
    • SOLVED QApplication, QLabel : no such file or directory
      Installation and Deployment • qlabel qapplication • • Genne  

      10
      0
      Votes
      10
      Posts
      1114
      Views

      PATH ? Why did you change that environment variable manually ?
    • SOLVED QLabel with specific options
      General and Desktop • qlabel flags • • TomNow99  

      5
      0
      Votes
      5
      Posts
      217
      Views

      @Bonnie It works! Thank you Sir or Madame!
    • UNSOLVED Qt C++ How can I show a users basic informations in a new window after login?
      General and Desktop • qlabel login label profile qt5 c++11 • • moslehuddin  

      2
      0
      Votes
      2
      Posts
      226
      Views

      The question is very general. So what exactly is the problem you cannot solve, and what have you coded so far?
    • SOLVED problem with aligning text underneath buttons
      General and Desktop • layout qlabel qpushbutton pyqt4 • • cerr  

      3
      0
      Votes
      3
      Posts
      255
      Views

      Hi, To add a layout to a layout there's the "addLayout" method.
    • UNSOLVED QScrollArea not expanding when QPixmap is loaded
      General and Desktop • qlabel qpixmap qscrollarea • • Conical  

      3
      0
      Votes
      3
      Posts
      271
      Views

      Hi, How did you set the QLabel on your QScrollArea ? If you put it in a layout on the scroll area then that's wrong.
    • UNSOLVED Setting QPixmap to Qlabel gives segmentation fault and app crashes
      General and Desktop • qt5 qimage qlabel qpixmap gstreamer1.0 • • vicky_mac  

      22
      0
      Votes
      22
      Posts
      1542
      Views

      Rather than giving the pointer to your MainWindow instance, pass directly the pointer to your label. Basically: mainwindow->ui->label
    • UNSOLVED Draw basic Axes on QPixmap ?
      General and Desktop • qlabel qpixmap qchart plot axis • • R-P-H  

      29
      0
      Votes
      29
      Posts
      2984
      Views

      Thanks for the support guys. I tried making a transparent QPixmap image using Qt::transparent fill for the axis and overlaying it onto my other QPixmap, however it didn't work properly. So I ended up just drawing directly onto the image itself. Not the most efficient method but it seems to work...
    • UNSOLVED Scaling pixmap images in qscrollarea
      General and Desktop • qlabel qpixmap qscrollarea • • rjmoses  

      4
      0
      Votes
      4
      Posts
      356
      Views

      @rjmoses Yes it will scale all images to match IconSize.
    • SOLVED Using a label to display large images in QT GUI
      General and Desktop • opengl qlabel opencv image display pixmap • • rtavakko  

      5
      0
      Votes
      5
      Posts
      1145
      Views

      An update on this. It works perfectly and its a very low-cost solution. My processing time remains almost the same (~10mS) using this method since the painter does the scaling for you when it draws. Thanks for your help guys.
    • SOLVED Add Qlabel as item in QTableview
      General and Desktop • qtableview qtablewidget qlabel qstandarditem • • sayan275  

      3
      0
      Votes
      3
      Posts
      2553
      Views

      @SGaist said in Add Qlabel as item in QTableview: QStyledItemDelegate Ok..I'll try with that. from google search maybe this kind of output it will give, which maybe as our requirement. Else, I have some lengthy approach..implement custom label with mousepressevent handled which emits the object name and add these custom labels, 20 in HLayout and add hlayouts in a vlayout... Thanks!
    • SOLVED How do I explicitely position QLabels?
      General and Desktop • qlabel setgeometry placement • • mdresser  

      3
      0
      Votes
      3
      Posts
      448
      Views

      @SGaist Thank you very much for the quick reply. I've removed both the horizontal and vertical layout boxes and everything works exactly as I want. Sometimes newbies make life more complicated for themselves than it needs to be! Thanks again!
    • UNSOLVED how can i increase font size of QLabel with help of Qwidget::setFont()?
      General and Desktop • qwidget qlabel qfont • • Yash001  

      6
      0
      Votes
      6
      Posts
      2370
      Views

      no, decrese the font size and see if it works. then you'll know whether you can change font size at all. If it works then that should be a hint as to why you cannot increase the size.
    • UNSOLVED Paint Event and Zoomed In Image Problem
      General and Desktop • qlabel size zoom painter paint event • • Nalu323  

      4
      0
      Votes
      4
      Posts
      749
      Views

      @mrjj I tried your code, here's the result:
    • SOLVED I have a problem text rendering with Qt 5.7(QML)
      General and Desktop • qml qt 5.7 qlabel text • • MintogoDeveloper  

      4
      0
      Votes
      4
      Posts
      1060
      Views

      I resolve it. I setted font of text as property of QML Text component. (Like font.family : parent.fontfamily) and on Qt 5.7's QML, there are no enough options to control font properties. so, I moved to C++ side and set a whole application font. QFont font = someClass.getLangFont(); //set property of font instance here // such as hinting policy, style etc. QApplication::setFont(font); now it looks very cleary... thank you..
    • UNSOLVED What's the fastest way to show JPG/JPEG images
      General and Desktop • qlabel qtimer streaming • • R_Irudezu  

      18
      0
      Votes
      18
      Posts
      4531
      Views

      Why are they not ?
    • UNSOLVED ImageViewer QLabel/QScrollArea top and bottom margins?
      General and Desktop • qlabel qscrollarea qguiapplication • • forlorn  

      6
      0
      Votes
      6
      Posts
      1304
      Views

      The Basic Drawing Example shows that. In your case, you'd likely just have to paint your image using the correct scaling information.
    • UNSOLVED how to keep good quality of label in terms of pixel while changing the font Size?
      General and Desktop • qlabel qstyle qwt qstylesheet qfont • • Yash001  

      11
      0
      Votes
      11
      Posts
      1841
      Views

      @SGaist got it.
    • SOLVED Update QLabel text in a loop
      General and Desktop • qlabel loop settext • • A Former User  

      3
      0
      Votes
      3
      Posts
      2935
      Views

      Thanks for your answer, unfortunately this part of my code is executed in a class that inherits from QMainWindow, I don't have access to the QApplication. Edit: It works using QCoreApplication::processEvents() instead.
    • UNSOLVED How to create FloatingLabels in Qt...?
      General and Desktop • qlabel qlinedit floatinglabel • • mounipanditi  

      1
      0
      Votes
      1
      Posts
      452
      Views

      No one has replied

    • UNSOLVED QLabel not loading image after changing computers
      General and Desktop • qwidget qlabel qicon • • SolaVitae  

      6
      0
      Votes
      6
      Posts
      1218
      Views

      Hi, What do you mean by regular string ? If it comes from the Windows API, you should then consider using QDir:: fromNativeSeparators.
    • UNSOLVED QT Qsplitter disable scrollbar on resizing QLabel
      General and Desktop • c++ qt qlabel scrollarea qt5.10 • • magicstar  

      9
      0
      Votes
      9
      Posts
      2731
      Views

      @SGaist I tried very hard. But, still am not satisfied with the implementation. And now am feeling helpless. If I set set, fixedsize for QLabel, then scroll bars won't appear if I use zoomout/zoomin. My question is why QLabel won't shrink back after changing size through Qsplitter. I tried all the combinations of sizepolicy and nothing has worked so far
    • SOLVED How to know when cursor is out of qlabel when clicked??
      General and Desktop • qlabel mouseevent • • vasu_gupta  

      8
      0
      Votes
      8
      Posts
      3174
      Views

      Hi should that not be pointer ? QRubberBand rubberBand; -> QRubberBand * rubberBand; (since you do rubberBand= new QRubberBand(QRubberBand::Rectangle,this) ) that would explain all 3 errors.
    • UNSOLVED horizontally Alligning dynamically created widgets qt c++
      General and Desktop • qtcreator qlabel qline horizontal alli nment • • Lasith  

      6
      0
      Votes
      6
      Posts
      1787
      Views

      What you need in fact is a QFormLayout (a subset of the grid layout) where you can insert the pairs of widgets with QFormLayout::addRow.