Page 2 of 2 FirstFirst 12
Results 21 to 25 of 25

Thread: How to show QLabels

  1. #21
    Join Date
    Dec 2008
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show QLabels

    You could be right. But the class in the source code has inheritance from QWidget.
    The QLabels didn't show with that properly as it was only first letter was seen from any label.

    The trick with QPainter did it's job - there is a loop for all required text and painter draws it:

    painter.drawText(x, y, text);

    Draw text with different color and different size is not a big deal. With color seems to be fine - just call painter.setPen(color). And after - painter.setFont(font)

    But now I am facing new problems - how can I make the window with all that information to be transparent?

    Best regards

    Pavel
    Last edited by Pavel Abrosimov; 8th July 2009 at 12:21.

  2. #22
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to show QLabels

    Quote Originally Posted by Pavel Abrosimov View Post
    The QLabels didn't show with that properly as it was only first letter was seen from any label.

    The trick with QPainter did it's job - there is a loop for all required text and painter draws it:

    painter.drawText(x, y, text);
    So what are the labels for if you're drawing the text manually?

    To me the problem seems to be caused by the fact that you are not using layouts and that you completely ignore setting geometry of the labels, so it's quite obvious you see nonsense.

    Qt Code:
    1. #include <QLabel>
    2. #include <QApplication>
    3.  
    4.  
    5. int main(int argc, char **argv){
    6. QApplication app(argc, argv);
    7. QWidget w;
    8. for(int i=0;i<10;i++){
    9. QLabel *l = new QLabel(&w);
    10. l->setText(QString("Label %1").arg(i+1));
    11. l->setGeometry(i*20, i*20, l->sizeHint().width(), l->sizeHint().height());
    12. }
    13. w.show();
    14. return app.exec();
    15. };
    To copy to clipboard, switch view to plain text mode 
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #23
    Join Date
    Dec 2008
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show QLabels

    As you said, there is no need in QLabels. And they are all taken away. There is just a sort of vector with all QStrings needed.

    How it is possible to make the background of the window transparent, but the text must be visible on it?

  4. #24
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to show QLabels

    Please search the forum. The issue has been brought up multiple times recently.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #25
    Join Date
    Dec 2008
    Posts
    18
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to show QLabels

    wysota thank you very much for your help.

    Best regards

    Pavel

Similar Threads

  1. problem with show Chinese
    By osmanthus in forum Qt Programming
    Replies: 1
    Last Post: 20th January 2009, 02:49
  2. How to show two main windows?
    By Althor in forum Newbie
    Replies: 4
    Last Post: 13th October 2008, 08:30
  3. Show dialog in screen center
    By mourad in forum Qt Programming
    Replies: 1
    Last Post: 16th June 2008, 13:41
  4. Rezizing the Qlabels vertically
    By anju123 in forum Qt Programming
    Replies: 3
    Last Post: 3rd January 2008, 15:35
  5. WYSIWYG html, Window show png icon mac no!
    By patrik08 in forum Qt Programming
    Replies: 10
    Last Post: 25th May 2006, 12:01

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.