Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Quickview and layouts



  • Hi,
    I have a mainwindow on which a QHBoxLayout is applied.
    To this 2 quickviews are added (which in turn 2 widgets are added) which house my tumbler.
    And both of these widgets are applied to the QHBoxLayout layout.

    In the background of the mainwindow a movie is running.
    But the quickview overlays this movie in white.
    If I apply a stretch it does shrink it but as you can see from the pic the top and bottom are still white.
    https://ibb.co/0s0qwPf
    Is there any way to just have the quickview cover the qml contents only leaving the surrounding area free to display the movie.
    I have tried anchors.fill: parent within qml but this doesn’t work.

    mstrWnd = new QWidget;                                                                                      //Creater main window widget
    mstrWnd->setObjectName(STR_MASTER_WINDOW_NAME);               
    mstrWnd->setWindowTitle(getSettingI(MSTR_APP_TITLE));                     //Assgin window title
    mstrWnd->setGeometry(getSettingI(MSTR_APP_X).toInt(),                       /Set default X position
    getSettingI(MSTR_APP_Y).toInt(),                                                                       //Set default Y position
    getSettingI(MSTR_APP_WIDTH).toInt(),                                                                 //Set default width
    getSettingI(MSTR_APP_HEIGHT).toInt());                                                              //Set default height
    mstrWnd->setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
    mstrWnd->setWindowState(Qt::WindowFullScreen);
    
    QHBoxLayout* laos = new QHBoxLayout();
    mstrWnd->setLayout(laos);
    quickView = new QQuickView(QUrl::fromLocalFile(QDir::currentPath() + "\\Resources\\videos\\aos.qml"));
    quickView->setResizeMode(QQuickView::SizeRootObjectToView);
    quickWidgettum = new QWidget;
    quickWidgettum = QWidget::createWindowContainer(quickView);
    quickWidgettum->setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
    laos->addWidget(quickWidgettum,15);
     
    quickViewdate = new QQuickView(QUrl::fromLocalFile(QDir::currentPath() + "\\Resources\\videos\\aosdate.qml"));
    quickViewdate->setResizeMode(QQuickView::SizeRootObjectToView);
    quickWidgetdate = new QWidget;
    quickWidgetdate = QWidget::createWindowContainer(quickViewdate);
    quickWidgetdate->setWindowFlags(Qt::FramelessWindowHint | Qt::Window);
    laos->addWidget(quickWidgetdate);
    
    QML
    Rectangle 
    {
    	width: 400
    	height: 400
    	x:115
    	y:230
    	Column 
    	{ 
    		/* outer column */
    		spacing: 10
    		Column 
    		{ /* inner column */
    			x: 10; y: 10
    			spacing: 10
    			Rectangle 
    			{ 
    				width: 180; height: 200; //color: "red" 
    				Frame 
    				{
    					FontMetrics 
    					{
    						id: fontMetrics
    					}
    					id: frame
    					padding: 0
    					Row 
    					{
    						id: row
    						Tumbler 
    						{ 							
    							id: hoursTumbler
    							objectName: "hour"
    							model: ["1", "2","3", "4","5", "6","7", "8","9", "10","11", "12"]
    							delegate: delegateComponent
    							readonly property int hourcode: hoursTumbler.currentIndex + 1
    						}
    
    						Tumbler 
    						{
    							id: minutesTumbler
    							objectName: "min"
    							model: 60
    							delegate: delegateComponent
    							readonly property int mincode: minutesTumbler.currentIndex
    						}
    
    						Tumbler 
    						{
    							objectName: "ampm"
    							id: amPmTumbler
    							model: ["AM", "PM"]
    							delegate: delegateComponent
    							readonly property string ampmcode: amPmTumbler.currentIndex
    						}
    					}
    				}
    			}
    		}
    	}
    }
    

  • Moderators

    @celica

    If I understand you correctly, than that is sadly not possible

    Your background video ( a widget?) and your QQuickView tumbler (qml) have different rendering methods, that don't play nicely with each other
    I was never able to correctly (partially)overlay one over the other



  • @J-Hilk Ah OK. Thanks for the answer.
    Is there any way to apply a static background image to the quickview so the white part at least is not in stark contrast


  • Moderators

    @celica
    sure,
    Rectangle has a color: property for the background and if you really want a Picture, replace the Rectangle with a Image object :)



  • @J-Hilk Great thanks.
    Would you know how to shrink the quickview so just the tumbler is visible as this is all that is in that widget within the quickview as in this pic - https://ibb.co/N3PXQdD



  • @J-Hilk Hi
    That worked great, thanks a lot.

    One last question. If you look at the pic attached.
    The second quickview widget (quickWidgetdate ) is shifted off to the right within the QHBoxlayout.
    Is there a way to move this over to the left manually.
    At the moment it is aligned to the center of the screen of the application on which it executes.

    https://ibb.co/jffdjJF


  • Moderators

    hi @celica sorry for the delay, busy weekend :)

    I'm not quite sure what is the cause for this. If you do not have a margin set in your Layout, than the issue has to be in the QML code. Could you post your QML code ?



  • @J-Hilk No problem. I actually resolved this in the meantime.
    What i did was instead of having 2 quickviews which were difficult to organize, I loaded both tumblers using one quickview instance. Thanks for the help.


Log in to reply