Results 1 to 5 of 5

Thread: How get max size text in a QPushButton (Qt embedded linux 4.3.0)

  1. #1
    Join Date
    Apr 2011
    Posts
    13
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default How get max size text in a QPushButton (Qt embedded linux 4.3.0)

    Hello!

    I'm trying to put a 200px text in a QPushButton, in Ubuntu X11 there isn't problem but when i crooscompile to linux embedded text is small. I'm using Qt 4.3.0.

    Anyone know how to solve the problem?

    I have tryied 2 ways, with next code, but not working :

    way 1:

    QPushButton temperature;
    Qt Code:
    1. temperature.setFlat(true);
    2. temperature.setText("300 degrees");
    3. temperature.setMaximumSize(QSize(291, 16777215));
    4. temperature.setStyleSheet("border: 0; background-color: transparent; font: 200px; font-family: Ubuntu");
    To copy to clipboard, switch view to plain text mode 

    way 2:
    Qt Code:
    1. QFont font;
    2. font.setFamily(QString::fromUtf8("Ubuntu"));
    3. font.setPointSize(200);
    4. font.setBold(true);
    5.  
    6. QPushButton temperature;
    7. temperature.setFlat(true);
    8. temperature.setText("300 degrees");
    9. temperature.setMaximumSize(QSize(291, 16777215));
    10. temperature.setFont(font);
    To copy to clipboard, switch view to plain text mode 
    Last edited by high_flyer; 26th July 2011 at 11:31. Reason: code tags

  2. #2
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How get max size text in a QPushButton (Qt embedded linux 4.3.0)

    does your display have 200px width where this string should appear?
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  3. #3
    Join Date
    Apr 2011
    Posts
    13
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How get max size text in a QPushButton (Qt embedded linux 4.3.0)

    Quote Originally Posted by high_flyer View Post
    does your display have 200px width where this string should appear?
    My display is 320x240 pixels. But it has a big central QPushButton. The button musts to show and resfresh 3 numbers.

  4. #4
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: How get max size text in a QPushButton (Qt embedded linux 4.3.0)

    What are the values of 'rect' when you add this code below?:
    Qt Code:
    1. QRect rect = temperature.geometry();
    To copy to clipboard, switch view to plain text mode 
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  5. #5
    Join Date
    Apr 2011
    Posts
    13
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    Unix/X11

    Default Re: How get max size text in a QPushButton (Qt embedded linux 4.3.0)

    Quote Originally Posted by high_flyer View Post
    What are the values of 'rect' when you add this code below?:
    Qt Code:
    1. QRect rect = temperature.geometry();
    To copy to clipboard, switch view to plain text mode 

    temperature is set:

    temperature.setGeometry(QRect(30, 70, 200, 80)); //posx,posy,sizex,sizey


    I'm thinking that the problem is the type of font, I'm using Arial

Similar Threads

  1. difference between source in Qt for X11/Linux Qt for Embedded Linux
    By sanjeet in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 7th June 2011, 02:58
  2. Replies: 0
    Last Post: 8th November 2010, 21:17
  3. Caching of QPushButton embedded in QGraphicsScene
    By matthias_ in forum Qt Programming
    Replies: 3
    Last Post: 1st October 2010, 19:31
  4. Multiple apps using Qt/Embedded+Qtopia on Embedded Linux
    By drahardja in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 17th February 2008, 21:46

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.