[Interest] QListView - make tab key behave like enter key

2019-03-18 Thread Frank Rueter | OHUfx

Hi all,

I have a simple QListView in which I would like to edit items by 
clicking into empty space, typing, then hitting either enter or tab.
I’d like the tab Key_Tab event to behave exactly like Key_Enter event, 
but it’s a bit stubborn.
When I hit tab while editing an item (i.e. editor is open), the first 
item in the list is selected.


I noticed that when hitting the tab key in an open editor only a 
QtCore.QEvent.ShortcutOverride is triggered.
It looks like I can simply react to that in my situation though I’m not 
sure if that is wise?!
If I do, how would I manually emit an event that looks like a Key_Enter 
event?


Otherwise, how can I avoid above behaviour for the tab key and make it 
behave like a regular key (I assume it’s trying to change focus in the 
focus chain but don’t know how to make it stop)?


Here is some example code to show my problem.

Cheers,
frank

|class AddresseeDelegate(QtWidgets.QItemDelegate): is_valid = 
QtCore.Signal() is_not_valid = QtCore.Signal(QtCore.QModelIndex) def 
__init__(self, users=[], groups=[], parent=None): 
super(AddresseeDelegate, self).__init__(parent) self.valid_item_texts = 
[u['name'] for u in users] + [g['code'] for g in groups] def 
createEditor(self, parent, option, index): self.editor = 
QtWidgets.QLineEdit(parent) self.editor.setMinimumWidth(100) completer = 
QtWidgets.QCompleter(self.valid_item_texts) 
completer.setCaseSensitivity(QtCore.Qt.CaseInsensitive) 
completer.setCompletionMode(QtWidgets.QCompleter.InlineCompletion) 
self.editor.setCompleter(completer) 
self.editor.editingFinished.connect(lambda: self.validate_text(index)) 
return self.editor def setModelData(self, editor, model, index): 
model.setData(index, editor.text()) def validate_text(self, index=None): 
if self.editor.text() in self.valid_item_texts: # valid input 
self.commitData.emit(self.editor) self.closeEditor.emit(self.editor) 
self.is_valid.emit() else: # invalid input 
self.closeEditor.emit(self.editor) self.is_not_valid.emit(index) class 
AddresseeListView(QtWidgets.QListView): def __init__(self, users=[], 
groups=[], parent=None): '''Simple addressee widget.''' 
super(AddresseeListView, self).__init__(parent) 
self.setEditTriggers(QtWidgets.QAbstractItemView.NoEditTriggers) 
self.setFlow(QtWidgets.QListView.LeftToRight) 
self.setResizeMode(QtWidgets.QListView.ResizeMode.Adjust) 
self.setSpacing(10) self.setViewMode(QtWidgets.QListView.IconMode) 
#self.setWrapping(True) # delegate delegate = AddresseeDelegate(users, 
groups) self.setItemDelegate(delegate) 
delegate.is_not_valid.connect(self.delete_invalid_index) # model model = 
QtGui.QStandardItemModel() #model = Model() self.setModel(model) def 
event(self, event): if event.type() == QtCore.QEvent.ShortcutOverride: # 
need to emit a Key_Enter event here event.accept() return 
super(AddresseeListView, self).event(event) def mousePressEvent(self, 
event): self.add_and_edit() def add_and_edit(self): '''Add a new row and 
open editor''' print 'adding row' new_item = QtGui.QStandardItem('') 
self.model().appendRow(new_item) 
self.edit(self.model().indexFromItem(new_item)) def 
delete_invalid_index(self, index): '''Remove invalid entry''' 
self.model().removeRow(index.row()) if __name__ == '__main__': app = 
QtWidgets.QApplication(sys.argv) users = [{'name':'aa'}, {'name':'bb'}] 
groups = [{'code':'cc'}, {'code':'dd'}] w = AddresseeListView(users, 
groups) w.show() w.raise_() app.exec_() |


​
--

ohufxLogo 50x50 
	*vfx compositing  | *workflow 
customisation and consulting * *

**
   


Your gateway to over 1,000 free tools... right inside of Nuke 



___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] How to detect a HiDPI display with Qt?

2019-03-18 Thread Thiago Macieira
On Monday, 18 March 2019 09:59:36 PDT Vadim Peretokin wrote:
> I'm not clear on how to detect if a display is HiDPI with Qt. I've tried
> QApplication.desktop()->screen()->devicePixelRatio() but even that returns
> 1 for a display that is 3840x2160.

That is the correct way. The problem is that the display in question is 
misconfigured.

qtdiag reports for me:

# 1 "DP1-1" Depth: 24 Primary: no
[...]
  Geometry: 1920x1080+3200+0 (native: 3840x2160+3200+0) Available: 
1920x1080+3200+0
  Virtual geometry: 5120x1080+0+0 Available: 5120x1080+0+0
  2 virtual siblings
  Physical size: 600x340 mm  Refresh: 30 Hz Power state: 0
  Physical DPI: 81.28,80.6824 Logical DPI: 108.373,108.427 (native: 
216.747,216.854) Subpixel_None
  High DPI scaling factor: 2 DevicePixelRatio: 2 Pixel density: 2
  Primary orientation: 2 Orientation: 2 Native orientation: 0 
OrientationUpdateMask: 0

Source (qtdiag.cpp):

str << "DevicePixelRatio: " << screen->devicePixelRatio()
<< " Pixel density: " << platformScreen->pixelDensity();

This is with QT_AUTO_SCREEN_SCALE_FACTOR=1
-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel System Software Products



___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] How to detect a HiDPI display with Qt?

2019-03-18 Thread Jérôme Godbout
I do Qml, so 

// C++, expose the m_image_scale as a meta property

class MyApp : public QObject
{
Q_OBJECT
Q_PROPERTY(QString imageScale read imageScale CONSTANT)
public:
// MyApp init should extract the string scale as previously stated, 
this function only returns the QString value.
QString imageScale() const;
};

// Qml

Image
{
  // Here you can make yourself a method, a sub folder if you want or whatever 
suites your needs.
  source: "qrc:///image/myImageName" + MyApp.imageScale + ".png"  
}

There's probably a better way to do it, but this I can track what is going on 
without fiddling too much into obscure under the hood undocumented behavior and 
the resource are inline with other iOS made images without too much renaming. 

-Original Message-
From: Interest  On Behalf Of 
william.croc...@analog.com
Sent: March 18, 2019 2:47 PM
To: interest@qt-project.org
Subject: Re: [Interest] How to detect a HiDPI display with Qt?


>
> You can also check the device pixel ratio for image “@2” alike:
>
> qreal pixel_ratio = QGuiApplication::primaryScreen()->devicePixelRatio();
>
> unsigned int image_scale_ratio=pixel_ratio/1u;
>
> QString
> m_image_scale = image_scale_ratio<=1u ? "" : 
> QString("@%1x").arg(image_scale_ratio);
>

Please keep going...

How do you use m_image_scale ?

Bill

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] How to detect a HiDPI display with Qt?

2019-03-18 Thread william.croc...@analog.com




You can also check the device pixel ratio for image “@2” alike:

qreal pixel_ratio = QGuiApplication::primaryScreen()->devicePixelRatio();

unsigned int image_scale_ratio=pixel_ratio/1u;

QString
m_image_scale = image_scale_ratio<=1u ? "" : 
QString("@%1x").arg(image_scale_ratio);



Please keep going...

How do you use m_image_scale ?

Bill

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] How to detect a HiDPI display with Qt?

2019-03-18 Thread Jérôme Godbout
You can also check the device pixel ratio for image “@2” alike:

qreal pixel_ratio = QGuiApplication::primaryScreen()->devicePixelRatio();
unsigned int image_scale_ratio = pixel_ratio / 1u;
QString m_image_scale = image_scale_ratio <= 1u ? "" : 
QString("@%1x").arg(image_scale_ratio);

This is what I do.

[36E56279]
une compagnie  [cid:image008.jpg@01D4DD95.0986ECD0]
RAPPROCHEZ LA DISTANCE

Jérôme Godbout
Développeur Logiciel Sénior /
Senior Software Developer

p: +1 (418) 800-1073 ext.:109

amotus.ca
statum-iot.com
[cid:image009.png@01D4DD95.0986ECD0]
 [cid:image010.png@01D4DD95.0986ECD0] 
  
[cid:image011.png@01D4DD95.0986ECD0]   
[cid:image012.jpg@01D4DD95.0986ECD0] 






From: Interest  On Behalf Of Jérôme Godbout
Sent: March 18, 2019 2:13 PM
To: Vadim Peretokin ; interestqt-project.org 

Subject: Re: [Interest] How to detect a HiDPI display with Qt?

You can check the dpi of the screen:
QGuiApplication::primaryScreen()->logicalDotsPerInch();

You can then check if the dpi is above certain threshold to do thing 
differently. Normal desktop full HD screen dpi is around 96.


[36E56279]
une compagnie  [cid:image014.jpg@01D4DD95.0986ECD0]
RAPPROCHEZ LA DISTANCE

Jérôme Godbout
Développeur Logiciel Sénior /
Senior Software Developer

p: +1 (418) 800-1073 ext.:109

amotus.ca
statum-iot.com
[cid:image015.png@01D4DD95.0986ECD0]
 [cid:image016.png@01D4DD95.0986ECD0] 
  
[cid:image017.png@01D4DD95.0986ECD0]   
[cid:image018.jpg@01D4DD95.0986ECD0] 






From: Interest 
mailto:interest-boun...@qt-project.org>> On 
Behalf Of Vadim Peretokin
Sent: March 18, 2019 1:00 PM
To: interestqt-project.org 
mailto:interest@qt-project.org>>
Subject: [Interest] How to detect a HiDPI display with Qt?

I'm not clear on how to detect if a display is HiDPI with Qt. I've tried 
QApplication.desktop()->screen()->devicePixelRatio() but even that returns 1 
for a display that is 3840x2160.

Has anyone got hints on how to do this successfully?
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] How to detect a HiDPI display with Qt?

2019-03-18 Thread Jérôme Godbout
You can check the dpi of the screen:
QGuiApplication::primaryScreen()->logicalDotsPerInch();

You can then check if the dpi is above certain threshold to do thing 
differently. Normal desktop full HD screen dpi is around 96.


[36E56279]
une compagnie  [cid:image002.jpg@01D4DD94.AA6DD510]
RAPPROCHEZ LA DISTANCE

Jérôme Godbout
Développeur Logiciel Sénior /
Senior Software Developer

p: +1 (418) 800-1073 ext.:109

amotus.ca
statum-iot.com
[cid:image003.png@01D4DD94.AA6DD510]
 [cid:image004.png@01D4DD94.AA6DD510] 
  
[cid:image005.png@01D4DD94.AA6DD510]   
[cid:image006.jpg@01D4DD94.AA6DD510] 






From: Interest  On Behalf Of Vadim Peretokin
Sent: March 18, 2019 1:00 PM
To: interestqt-project.org 
Subject: [Interest] How to detect a HiDPI display with Qt?

I'm not clear on how to detect if a display is HiDPI with Qt. I've tried 
QApplication.desktop()->screen()->devicePixelRatio() but even that returns 1 
for a display that is 3840x2160.

Has anyone got hints on how to do this successfully?
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] How to detect a HiDPI display with Qt?

2019-03-18 Thread Vadim Peretokin
I'm not clear on how to detect if a display is HiDPI with Qt. I've tried
QApplication.desktop()->screen()->devicePixelRatio() but even that returns
1 for a display that is 3840x2160.

Has anyone got hints on how to do this successfully?
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


Re: [Interest] Qt on direct compose

2019-03-18 Thread Giuseppe D'Angelo via Interest

Hi,

On 18/03/2019 14:32, Pierre Lamot wrote:

Before starting to perform a draw call, DComposition will inform you where it
expect you to perform your drawing within the texture it gives you, like an
OpenGL viewport.  In most cases this will be (0,0) and  will works out of the
box. Though, especially when dealing with small resolution, DComposition will
recycle its texture and ask you to draw with a different viewport. I didn't 
find a
way to specify the viewport on Qt side, it seems to reset it before drawing the
scene (probably [4]) .
So my question is, is there any way I can tell Qt what viewport to use?


Maybe there's a small bit of API missing here on QQuickWindow, to 
specify the viewport that Qt Quick should use when rendering on a FBO? 
(I'd suggest to open a feature request for this, should be relatively 
simple to implement...).


Given the codepath that you pasted, there seems to be no way for a 
custom glViewport in there. And I wouldn't recommend using QSGEngine, 
the effort is definitely not worth it here.


My 2 c,
--
Giuseppe D'Angelo | giuseppe.dang...@kdab.com | Senior Software Engineer
KDAB (France) S.A.S., a KDAB Group company
Tel. France +33 (0)4 90 84 08 53, http://www.kdab.com
KDAB - The Qt, C++ and OpenGL Experts



smime.p7s
Description: S/MIME Cryptographic Signature
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] Qt on direct compose

2019-03-18 Thread Pierre Lamot
Hello, 

I'm trying to render to  QML to Direct Composition [1] surfaces. 
This can be achieve by getting Qt to render its scene to a special PBO created 
by ANGLE.
I got this part working by following advises from [2] and [3].

Before starting to perform a draw call, DComposition will inform you where it 
expect you to perform your drawing within the texture it gives you, like an 
OpenGL viewport.  In most cases this will be (0,0) and  will works out of the 
box. Though, especially when dealing with small resolution, DComposition will 
recycle its texture and ask you to draw with a different viewport. I didn't 
find a 
way to specify the viewport on Qt side, it seems to reset it before drawing the 
scene (probably [4]) . 
So my question is, is there any way I can tell Qt what viewport to use?

To make thing more clear, or if this interest someone else, my code is 
available at [5]

[1] https://docs.microsoft.com/en-us/windows/desktop/api/_directcomp/
[2] https://lists.qt-project.org/pipermail/interest/2015-September/018977.html
[3] https://lists.qt-project.org/pipermail/interest/2015-September/019047.html
[4] 
https://code.woboq.org/qt5/qtdeclarative/src/quick/items/qquickwindow.cpp.html#463
  
[5] https://github.com/chubinou/QtOnDirectCompose/

thanks.

--
Pierre Lamot



___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest