[libcamera-devel] [PATCH 2/2] qcam: main_window: Fix combo-box entry selection on startup

Umang Jain email at uajain.com
Thu Apr 30 17:46:07 CEST 2020


Hi Laurent,

On Thu, Apr 30, 2020 at 18:36, Laurent Pinchart 
<laurent.pinchart at ideasonboard.com> wrote:
> Hi Umang,
> 
> On Thu, Apr 30, 2020 at 04:07:41PM +0100, Kieran Bingham wrote:
>>  On 30/04/2020 15:15, Umang Jain wrote:
>>  > When one of the camera is selected and opened from the
>>  > "Select Cameras" items list, the entry of the combo-box
>>  > in the main-window doesn't update its item index to reflect
>>  > the camera which was earlier selected. Fix that.
>> 
>>  Ohh - nice catch - thanks, tested with and without this patch and I 
>> see
>>  what you mean!
>> 
>>  Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com 
>> <mailto:kieran.bingham at ideasonboard.com>>
>>  Tested-by: Kieran Bingham <kieran.bingham at ideasonboard.com 
>> <mailto:kieran.bingham at ideasonboard.com>>
>> 
>>  > Signed-off-by: Umang Jain <email at uajain.com 
>> <mailto:email at uajain.com>>
>>  > ---
>>  >  src/qcam/main_window.cpp | 4 ++++
>>  >  1 file changed, 4 insertions(+)
>>  >
>>  > diff --git a/src/qcam/main_window.cpp b/src/qcam/main_window.cpp
>>  > index 344b7ec..fa05515 100644
>>  > --- a/src/qcam/main_window.cpp
>>  > +++ b/src/qcam/main_window.cpp
>>  > @@ -249,6 +249,10 @@ int MainWindow::openCamera()
>>  >  		return -EBUSY;
>>  >  	}
>>  >
>>  > +	/* Set the combo-box with the current selected Camera */
>>  > +	int camIndex = 
>> cameraCombo_->findText(QString::fromStdString(cameraName));
>>  > +	cameraCombo_->setCurrentIndex(camIndex);
> 
> How about
> 
> 	cameraCombo_->setCurrentText(QString::fromStdString(cameraName));
> 
> ?

Oh yes, that's quite good. From documentation, it seems setCurrentText()
will do, what is being done in this patch much explicitly.

 > The setter setCurrentText() simply calls setEditText() if the combo 
box is editable.
     Otherwise, if there is a matching text in the list, currentIndex 
is set to the corresponding index.

Thanks.
> 
> With that change, or without it if it doesn't work,
> 
> Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com 
> <mailto:laurent.pinchart at ideasonboard.com>>
> 
>>  > +
>>  >  	return 0;
>>  >  }
>>  >
> 
> --
> Regards,
> 
> Laurent Pinchart

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.libcamera.org/pipermail/libcamera-devel/attachments/20200430/32284c4d/attachment-0001.htm>


More information about the libcamera-devel mailing list