Results 1 to 9 of 9

Thread: Application's window not showing properly in a touchscreen

  1. #1
    Join Date
    Jun 2019
    Location
    France, Pau
    Posts
    60
    Thanks
    32
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Application's window not showing properly in a touchscreen

    Hello Qt Experts,

    With a touchscreen (Chalkboard Electronics) and under Ubuntu (using Openbox as a window manager), I am unable to display properly my application's window (maximized upon showing):

    folog_touchscreen.jpg

    The application's window with a normal screen (and another OS) :

    folog_normal_screen.jpg

    Can someone tell me what's going wrong (dpi issue ?) and how can I fix this issue ?

    Below, the output of xrandr :
    Screen 0: minimum 8 x 8, current 1366 x 768, maximum 32767 x 32767
    HDMI-0 connected primary 1366x768+0+0 (normal left inverted right x axis y axis) 220mm x 120mm
    1366x768 60.00*+
    1920x1080 60.00
    1280x720 60.00 59.94 50.00
    1024x768 60.01
    800x600 60.32
    720x576 50.00
    640x480 59.94
    DP-0 disconnected (normal left inverted right x axis y axis)
    DP-1 disconnected (normal left inverted right x axis y axis)
    Thank you very much.

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Application's window not showing properly in a touchscreen

    The problem may not be a DPI problem as much as it is a problem with the choice of fonts and widget sizes used in your layout. First, it looks like you have chosen a font that is too large in the left-hand panel of your splitter. In addition, your labels are too long for one line - you should try to split them over two lines if possible. On the right-hand side, it looks like you have set a minimum width for the plot window that is too large. As a result, the tab widget can't shrink to fit everything onscreen. (If the plot widget was allowed to resize smaller, then the tab widget would likely look different - instead of the tabs being chopped off, there would be a handle to permit you to scroll right for more tabs. Therefore I conclude your plot widget's minimum size is too large).

    Just guessing what's wrong from having seen similar problems in the past and tracing it back to bad choices made when laying out the UI.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  3. The following user says thank you to d_stranz for this useful post:

    embeddedmz (31st July 2019)

  4. #3
    Join Date
    Jun 2019
    Location
    France, Pau
    Posts
    60
    Thanks
    32
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Application's window not showing properly in a touchscreen

    Hi d_stranz,

    Thanks for your reply. In both screenshots, I am using the same font (I didn't change the font in the code, I kept the default one: Abyssinica SIL, size 10). I don't know why in the touchscreen it appears bigger than in normal screen version (DPI stuff ?) Otherwise, I have to be careful : I just can't reduce the buttons size for example, it could prevent a user from pressing (tapping) them (I implemented a virtual keyboad by the way...).

    Is it possible to apply a default font (interested only on size) to all the app's QWidgets ?

    I forgot to mention that I don't understand why in the left panel some elements are not showing completely ? (e.g. Range radio buttons and Save/Display checkboxes). I thought using layouts prevents this kind of problems ??!? and anyway, the window exceeds the dimensions of the screen, so why Qt is not letting these elements expand correctly ?

    I made some changes, the geometry of the window, as seen from Qt Creator, is now 1218 x 697, but in the touchscreen the window is still exceeding though I'm below the touchscreen resolution.

    I am not using a splitter, panel and plots are arranged in a grid layout (and their elements are arranged in vertical layouts).

  5. #4
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application's window not showing properly in a touchscreen

    Quote Originally Posted by embeddedmz View Post
    Is it possible to apply a default font (interested only on size) to all the app's QWidgets ?
    Qt Code:
    1. QApplication::setFont( new_font );
    2. foreach(QWidget *widget, QApplication::allWidgets())
    3. {
    4. widget->setFont(new_font);
    5. widget->update();
    6. }
    To copy to clipboard, switch view to plain text mode 

  6. #5
    Join Date
    Jun 2019
    Location
    France, Pau
    Posts
    60
    Thanks
    32
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Application's window not showing properly in a touchscreen

    I think I understood the problem (or excatly what d_stranz said) : sizes of checkboxes and radiobuttons are in pixels right ? so in small screen (for instance the touchscreen), they may not appear completely isn't it ?

    With a ruler, I checked that the text labels have the same length in both screen, but not the buttons or the other graphical widgets.

    I don't know if there's a technique to create a widget by defining its size not in pixels but in centimeters for example so it can be displayed the same whatever the screen used.

    UPDATE: I really don't understand what's going on...
    Last edited by embeddedmz; 31st July 2019 at 16:37.

  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Application's window not showing properly in a touchscreen

    @Lesiok: If you set the QApplication font before creating any widgets (eg. in main()), then the loop to set the font in the app's widgets is not needed. Your loop code is needed if you want to change it on-the-fly after the GUI has been built. I would be curious to know if setting the font dynamically would also result in a re-layout of the UI and resizing of widgets where needed.

    @embeddedmz: The QScreen class has methods that return many of the physical and logical properties of the display device. If you are able to debug the code on your embedded device, you might add some calls to retrieve the geometry() of various widgets, maybe in their showEvent(). The show event is called after the widget is fully laid out and sized, so it should contain the true pixel dimensions of the widget. It might give some clues as to why your widgets are being clipped.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

  8. #7
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Application's window not showing properly in a touchscreen

    Quote Originally Posted by d_stranz View Post
    @Lesiok: If you set the QApplication font before creating any widgets (eg. in main()), then the loop to set the font in the app's widgets is not needed. Your loop code is needed if you want to change it on-the-fly after the GUI has been built. I would be curious to know if setting the font dynamically would also result in a re-layout of the UI and resizing of widgets where needed.
    Yes, I know. This is the code to change the font in a running application without restarting.

  9. #8
    Join Date
    Jun 2019
    Location
    France, Pau
    Posts
    60
    Thanks
    32
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Application's window not showing properly in a touchscreen

    I found the problem : the panel had a maximal width size set to 400 (instead of the usual big number), I lost one day or two because of that...

    I can handle the rest of the small issues. Thanks everybody !

  10. #9
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Application's window not showing properly in a touchscreen

    Been there, done that. Eventually you learn that Qt is smarter than you are and leave the defaults alone :-)
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. QScrollArea Not Showing Properly
    By tvj4218 in forum Newbie
    Replies: 2
    Last Post: 28th January 2017, 01:22
  2. ToolBar Below mainToolBar not showing properly
    By ajMatus in forum Qt Programming
    Replies: 1
    Last Post: 18th March 2016, 23:32
  3. touchscreen tslib kernel event debugging qt application
    By sean_h in forum Qt for Embedded and Mobile
    Replies: 4
    Last Post: 14th September 2012, 08:30
  4. how to enable touchscreen for qt application in imx51 board??
    By shakthi in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 17th November 2011, 17:11
  5. Get window size prior to showing window?
    By mortoray in forum Qt Programming
    Replies: 0
    Last Post: 13th January 2011, 17:52

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.