QT5 Title bar obscures top row of buttons on Windows 10 - qt

My PyQT5 application is working fine on Linux, macOS and some Windows PCs, but on some Windows 10 PCs the top row of buttons is obscured by the window frame / title bar:
Not only are the buttons obscured, you have to click below the buttons in order to click on them, so the click locations appear to be correct but the buttons are shown above the click locations.
The buttons are created in a QT Creator UI file as follows:
<widget class="QMainWindow" name="MainWindow">
<widget class="QWidget" name="centralwidget">
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0" colspan="10">
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QPushButton" name="OpenButton">
Versions: PyQt 5.6.0, qt5.6.2 from Miniconda

As indicated by #Arpegius, this turns out to be due to the Intel Graphics Driver (see QT bug 62127.
The problem disappears if I configure the QT application to use my NVidia adapter instead of my Intel adapter.

Related

My custom widget is not shown in Qt Creator / Qt Designer but it is shown when I execute the program

I would like to have a QTabWidget with a tab containing a custom widget.
I created a custom Widget (consisting of a .ui, .h and .cpp file)
I added this custom Widget to the first page of my QTabWidget, but the content of this Widget is not shown in QtCreator's designer.
I promoted my custom Widget as Tab1Custom.
This setup compiles and works as expected when I run the program, but my custom control doesn't show up in QtCreator's designer.
What can I do to make my custom control show up in QtCreator's designer?
Here's the first part of MainWindow.ui:
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>MainWindow</class>
<widget class="QMainWindow" name="MainWindow">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>800</width>
<height>600</height>
</rect>
</property>
<property name="windowTitle">
<string>my title </string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QTabWidget" name="tabWidget">
<property name="geometry">
<rect>
<x>0</x>
<y>10</y>
<width>801</width>
<height>551</height>
</rect>
</property>
<property name="currentIndex">
<number>0</number>
</property>
<widget class="Tab1Custom" name="myTab1">
<attribute name="title">
<string>My Tab number 1</string>
</attribute>
</widget>
....
This is how it works when you use a custom widget and promote it. In order to have your widget drawn with content, you have to create a DLL to extend Qt Designer. Look at "Creating Custom Widgets for Qt Designer" for more information on that.
For the most part, I don't think it's worth the effort to do this; generally speaking, it's fine that it just shows a either a blank widget or whatever base widget you promoted.

Why QSpinBox get focus when focusPolicy = NoFocus

Why QSpinBox receives focus at pressed Shift + Tab? How to fix?
Example:
Create a form as in picture 1.
Set spinBox_2 and pushButton_2 focusPolicy = NoFocus
Start, and try to press Tab several times, and to press Shift+Tab.
We see that spinBox_2 get focus.
OC: windows 10. Qt 5.12.3.
in *.ui file
mainwindow.ui
<widget class="QSpinBox" name="spinBox_2">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QPushButton" name="pushButton_2">
<property name="focusPolicy">
<enum>Qt::NoFocus</enum>
</property>
<property name="text">
<string>PushButton</string>
</property>
</widget>
</item>
To answer your question "Why?", it's because it is a bug.
If you have time you can file a bug: https://bugreports.qt.io/
Tried to set the tab order to not to letting spinBox_2 selected?
See Qt Designer's Tab Order Editing Mode

Qt button take as much space as the text on it needs

I have a button in Qt Designer and I want it to take always as much space as the text on it needs. How can i accomplish that?
I mean like the text on the button is "Hello" and the button will be 45px.
When I do self.button.setText("Hello World") the button will be 85px.
My current "servers.ui":
<item>
<widget class="QPushButton" name="pageLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="maximumSize">
<size>
<width>40</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="flat">
<bool>true</bool>
</property>
</widget>
</item>
I'm actually talking about:
Use a QToolButton instead of a QPushButton and clear its maximum size.
You may need to set the vertical size-policy to "Preferred" so that it to has the same height as the other buttons. To get a flat button, check the "autoRaise" property.
A quick way to change the button class is to right-click it and select "Morph Into" from the context menu.

Recycle bin in Alfresco Share

I wonder if it's possible to add a "recycle bin" button in the Alfresco share header.
(source: alfresco.com)
As of 4.2 the trashcan is available to any user. It is a link in their profile. For example, to go to the trash can directly via URL, the link is:
https://localhost:8080/share/page/user/[USER_NAME]/user-trashcan
So it should be a trivial customization to add a link to this in the Share header.
But you need to know that the trashcan at the moment is admin only. There is JIRA, but it hasn't been fixed yet.
So without some heavy customization you can bring the button to the menu, but you'll need to be an admin.
There is a cool addon which shows the button on your personal profile:
https://forums.alfresco.com/forum/developer-discussions/add-ons/personal-user-trash-can-07192013-1200
https://github.com/atolcd/alfresco-my-deleted-items
I've been trying with the deployment of these modules, but I've not been successful. The installation of these modules have attempted using the MMT and AMP modes.
As Jeff already mentioned it strongly depends on the version you are running. From 4.2.x on you can add a line to the following file:
tomcat/webapps/share/WEB-INF/classes/alfresco/share-config.xml
add the following line:
<item type="link" id="trash" label="Trash">/user/{userid}/user-trashcan</item>
and set legacy mode to true:
<legacy-mode-enabled>true</legacy-mode-enabled>
then it will look like:
<!-- This indicates whether or not to use the configuration defined in this "header" element for rendering
the header menu bar. If this is set to "false" or it not defined then the header bar will be rendered
using the design implemented for 4.2 Enterprise. The header definition can be found in the associated
WebScript controller.
-->
<legacy-mode-enabled>true</legacy-mode-enabled>
<!-- This is the configuration that will be used to populate the header menu bar when "legacy-mode-enabled"
has been set to true -->
<app-items>
<!-- defaults: icon="{id}.png" label="header.{id}.label" description="header.{id}.description" -->
<item type="link" id="my-dashboard">{userdashboardpage}</item>
<item type="js" id="sites">Alfresco.module.Sites</item>
<item type="link" id="people">/people-finder</item>
<item type="link" id="repository" condition="conditionRepositoryRootNode">/repository</item>
<item type="link" id="trash" label="Trash">/user/{userid}/user-trashcan</item>
<item type="container" id="more">
<container-group id="my">
<item type="link" id="my-tasks">/my-tasks#filter=workflows|active</item>
<item type="link" id="my-workflows">/my-workflows#filter=workflows|active</item>
<item type="link" id="my-content">/user/user-content</item>
<item type="link" id="my-sites">/user/user-sites</item>
<item type="link" id="my-profile">{userprofilepage}</item>
</container-group>
<container-group id="tools" permission="admin">
<item type="link" id="application">/console/admin-console/application</item>
<item type="link" id="groups">/console/admin-console/groups</item>
<item type="link" id="replication-jobs" condition="!conditionEditionTeam">/console/admin-console/replication-jobs</item>
<item type="link" id="repository">/console/admin-console/repository</item>
<item type="link" id="trashcan">/console/admin-console/trashcan</item>
<item type="link" id="users">/console/admin-console/users</item>
<item type="link" id="more">/console/admin-console/</item>
</container-group>
</item>
</app-items>
the original trashcan entry within the container group will not work any more as it links to the old before V4.2 admin trash can. You can remove that line if you like.

Qt manually change the ratio between items in layout

I have two QTreeViews in a QHBoxLayout.
<layout class="QHBoxLayout" name="lay_disk_content">
<item>
<widget class="QTreeView" name="lay_disk_tvA">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
</item>
<item>
<widget class="QTreeView" name="lay_disk_tvB">
<property name="editTriggers">
<set>QAbstractItemView::NoEditTriggers</set>
</property>
</widget>
</item>
</layout>
When I resize the QMainWindow the two QTreeViews get resized with an 1:1 ratio between them. Now I would like to manually change it in the running program through dragging the space between them. This is somewhat a standard behavior but I don't get the name of it.
QSplitter

Resources