Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Most widgets obscured, covered up by black
Forum Updated to NodeBB v4.3 + New Features

Most widgets obscured, covered up by black

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 4 Posters 2.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gibbogle
    wrote on last edited by
    #1

    (Sorry to be monopolising this forum.)
    This is a strange one. The application that I'm porting from Windows to Linux is basically working now (as long as it is invoked in a terminal). But all the input screens are displayed with a flood of black that covers up most (but strangely not all) of the field labels. The situation is best conveyed by screenshots - the two attached pics are for one of the input screens,
    with Linux
    0_1568776891830_CaptureLinux.png ,

    and with Windows:
    0_1568776986144_CaptureWindows.PNG
    The screen widget (tab_run) has this location in Designer:
    MainWQindow (QMainWindow)
    ----centralWidget (QWidget)
    --------stackedWidget (QStackedWidget)
    ------------tabs (QTabWidget)
    ----------------tab_run (QWidget)

    (There is a misalignment issue with the field labels, but that is just a font size issue.)

    J.HilkJ 1 Reply Last reply
    0
    • G gibbogle

      (Sorry to be monopolising this forum.)
      This is a strange one. The application that I'm porting from Windows to Linux is basically working now (as long as it is invoked in a terminal). But all the input screens are displayed with a flood of black that covers up most (but strangely not all) of the field labels. The situation is best conveyed by screenshots - the two attached pics are for one of the input screens,
      with Linux
      0_1568776891830_CaptureLinux.png ,

      and with Windows:
      0_1568776986144_CaptureWindows.PNG
      The screen widget (tab_run) has this location in Designer:
      MainWQindow (QMainWindow)
      ----centralWidget (QWidget)
      --------stackedWidget (QStackedWidget)
      ------------tabs (QTabWidget)
      ----------------tab_run (QWidget)

      (There is a misalignment issue with the field labels, but that is just a font size issue.)

      J.HilkJ Offline
      J.HilkJ Offline
      J.Hilk
      Moderators
      wrote on last edited by
      #2

      @gibbogle this seems to me like a stylesheet issue. Do you use stylesheets and do you set the background-color for any of your widgets?

      I would guess no :)


      Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


      Q: What's that?
      A: It's blue light.
      Q: What does it do?
      A: It turns blue.

      G 2 Replies Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi,

        To add to @J-Hilk, what desktop environment are you using on Linux ? Does it have a dark theme ?
        Are you using the distribution provided Qt ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        G 1 Reply Last reply
        0
        • J.HilkJ J.Hilk

          @gibbogle this seems to me like a stylesheet issue. Do you use stylesheets and do you set the background-color for any of your widgets?

          I would guess no :)

          G Offline
          G Offline
          gibbogle
          wrote on last edited by gibbogle
          #4

          @j-hilk
          I don't know anything about stylesheets, and don't (knowingly) use them.
          No, I don't set a background color for any widgets.

          Edit: I should mention that it is only on the tabs member screens that this problem occurs. The other widgets that are members of stackedWidget do not have this problem.

          1 Reply Last reply
          0
          • SGaistS SGaist

            Hi,

            To add to @J-Hilk, what desktop environment are you using on Linux ? Does it have a dark theme ?
            Are you using the distribution provided Qt ?

            G Offline
            G Offline
            gibbogle
            wrote on last edited by
            #5

            @sgaist
            Whatever desktop environment I'm using is that which comes with Ubuntu 18.04, by default. I just installed 18.04 a few days ago and have changed nothing. How do I find out about my desktop environment?
            The Qt distribution is that installed by:
            qt-opensource-linux-x64-5.13.0.run

            1 Reply Last reply
            0
            • J.HilkJ J.Hilk

              @gibbogle this seems to me like a stylesheet issue. Do you use stylesheets and do you set the background-color for any of your widgets?

              I would guess no :)

              G Offline
              G Offline
              gibbogle
              wrote on last edited by
              #6

              @j-hilk
              I found some helpful suggestions, and did this in main.cpp:

              mainWin.showMaximized();
              //specify a new font.
              QFont newFont("Helvetica", 10, QFont::Normal, false);
              //set font of application
              QApplication::setFont(newFont);
              foreach (QWidget *widget, QApplication::allWidgets()) {
                  widget->setFont(QApplication::font());
                  widget->setStyleSheet("background-color:white;");
                  widget->update();
              }
              

              and this has solved the black problem!
              The alignment and sizing of many widgets is a bit different from in Windows, and requires some adjustments, but that's a relatively trivial issue.

              The global setting of widget fonts like this is effective, but not ideal, since it overrides any wanted variations introduced in Design. I guess what I really want is to scale the widget fonts globally - is that possible?

              J.HilkJ G 2 Replies Last reply
              1
              • G gibbogle

                @j-hilk
                I found some helpful suggestions, and did this in main.cpp:

                mainWin.showMaximized();
                //specify a new font.
                QFont newFont("Helvetica", 10, QFont::Normal, false);
                //set font of application
                QApplication::setFont(newFont);
                foreach (QWidget *widget, QApplication::allWidgets()) {
                    widget->setFont(QApplication::font());
                    widget->setStyleSheet("background-color:white;");
                    widget->update();
                }
                

                and this has solved the black problem!
                The alignment and sizing of many widgets is a bit different from in Windows, and requires some adjustments, but that's a relatively trivial issue.

                The global setting of widget fonts like this is effective, but not ideal, since it overrides any wanted variations introduced in Design. I guess what I really want is to scale the widget fonts globally - is that possible?

                J.HilkJ Offline
                J.HilkJ Offline
                J.Hilk
                Moderators
                wrote on last edited by
                #7

                @gibbogle

                Not necessarily how I would have done it, but hey it works 😉

                Don't forget to set the topic via topic tools to solved!
                Happy coding


                Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                Q: What's that?
                A: It's blue light.
                Q: What does it do?
                A: It turns blue.

                G 1 Reply Last reply
                0
                • J.HilkJ J.Hilk

                  @gibbogle

                  Not necessarily how I would have done it, but hey it works 😉

                  Don't forget to set the topic via topic tools to solved!
                  Happy coding

                  G Offline
                  G Offline
                  gibbogle
                  wrote on last edited by
                  #8

                  @j-hilk
                  Feel free to suggest a better way. Any suggestions about how to reduce the font size while preserving, for example, the distinction between bold (e.g. titles) and normal text?

                  J.HilkJ 1 Reply Last reply
                  0
                  • G gibbogle

                    @j-hilk
                    Feel free to suggest a better way. Any suggestions about how to reduce the font size while preserving, for example, the distinction between bold (e.g. titles) and normal text?

                    J.HilkJ Offline
                    J.HilkJ Offline
                    J.Hilk
                    Moderators
                    wrote on last edited by
                    #9

                    @gibbogle
                    well, take a look at the high dpi display page of the documentation
                    https://doc.qt.io/qt-5/highdpi.html

                    Useful to read anyway.

                    What you're looking for is probably QT_SCALE_FACTOR which effects all fonts, scaled.

                    It's an environment variable an can be set inside your code

                    qputenv("QT_SCALE_FACTOR", "1.5");
                    

                    Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                    Q: What's that?
                    A: It's blue light.
                    Q: What does it do?
                    A: It turns blue.

                    G 1 Reply Last reply
                    2
                    • J.HilkJ J.Hilk

                      @gibbogle
                      well, take a look at the high dpi display page of the documentation
                      https://doc.qt.io/qt-5/highdpi.html

                      Useful to read anyway.

                      What you're looking for is probably QT_SCALE_FACTOR which effects all fonts, scaled.

                      It's an environment variable an can be set inside your code

                      qputenv("QT_SCALE_FACTOR", "1.5");
                      
                      G Offline
                      G Offline
                      gibbogle
                      wrote on last edited by
                      #10

                      @j-hilk
                      Excellent! Just what I wanted. Thanks a lot.
                      Everything is working now, except that I can't trigger the execution within Qt Creator.

                      1 Reply Last reply
                      0
                      • G gibbogle

                        @j-hilk
                        I found some helpful suggestions, and did this in main.cpp:

                        mainWin.showMaximized();
                        //specify a new font.
                        QFont newFont("Helvetica", 10, QFont::Normal, false);
                        //set font of application
                        QApplication::setFont(newFont);
                        foreach (QWidget *widget, QApplication::allWidgets()) {
                            widget->setFont(QApplication::font());
                            widget->setStyleSheet("background-color:white;");
                            widget->update();
                        }
                        

                        and this has solved the black problem!
                        The alignment and sizing of many widgets is a bit different from in Windows, and requires some adjustments, but that's a relatively trivial issue.

                        The global setting of widget fonts like this is effective, but not ideal, since it overrides any wanted variations introduced in Design. I guess what I really want is to scale the widget fonts globally - is that possible?

                        G Offline
                        G Offline
                        Go Fish
                        wrote on last edited by Go Fish
                        #11

                        @gibbogle I should noe that setting font using setFont() on a widget with QSS not guaranteed to work (it shouldn't work but in someversions and patforms it does). These are related to two different ways to render windet.
                        A call to

                        widget->setAutoFillBackground(true);
                        

                        should have same result here. Upscaling and other visual effects require autofiling or background will be black. QSS use equals to activating autofill.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved