Is there a way of doing this without using a QItemDelegate? I've been having a lot of trouble with it. For example, if I use a Delegate:
Won't have a native dialog.
I'll have to implement my own image preview,
For some reason I can't resize the window cause setGeometry doesn't work, etc etc.
QWidget *createEditor(
QWidget *parent,
const QStyleOptionViewItem &option,
const QModelIndex &index
) const {
Q_UNUSED(option);
Q_UNUSED(index);
QFileDialog* editor = new QFileDialog(parent);
editor->setFilter("*.png");
editor->setDirectory(mResources);
editor->setGeometry(0,0,1000,500);
editor->exec() // <--- big file dialog;
return editor; // <--- tiny file dialog;
};
In practice, everything that changes the geometry of your widget goes to updateEditorGeometry function. Override it to avoid trying the original one to put your dialog within the cell of the table.
OK so the editor->setGeometry method has to go in the overridden method setEditorData of the QItemDelegate.
Does anyone know of an example code where the setItemDelegate is used to paint the thumbnail preview of the images in the QFileDialog?
Related
I am trying to implement swipe actions on ListView for each element. Whole view is AbsoluteLayout, with two GridLayouts: one acting as "foreground"(list element) and other as "background" (swipe actions). I want them both to have equal height of "foreground" (which is dynamic and differs for every list element).
I succesfully implemented this on Android - I call a method on layoutChanged event
onLayoutChanged(args: EventData) {
const foregroundNotificationTemplate = (<AbsoluteLayout>(args.object)).getChildAt(1);
const backgroundButtons = (<AbsoluteLayout>args.object).getChildAt(0);
backgroundButtons.height = foregroundNotificationTemplate.getActualSize().height;
}
This unfortunatelly is not working on iOS. I tried to access Frame and UiView, but with no success - it has height of background content.
Demo presenting the problem on Nativescript Playground:
https://play.nativescript.org/?template=play-ng&id=4LRwDC
You don't necessarily have to use AbsoluteLayout as you are animating the position with translate which is possible with any layout. So using GridLayout instead of AbsoluteLayout should solve your problem on both platforms and you may also get rid layoutChanged event for measuring height.
Also note that your ListView item template can not be dynamic, you should not use ngIf or anything that would alter the structure of the list item, use multiple templates instead.
For anyone looking for working solution, thats what Manoj proposed: https://play.nativescript.org/?template=play-ng&id=yXggcv
I have a fiddle at http://jsfiddle.net/k8XCP/1/ where I'm trying to create a helper that consists of the original thumb being dragged plus an image that shows the user a tip. It's trying to work, but it has two problems:
The combined helper being dragged (newHelper) starts off where the newHelper div was laid down, even though I try to set the newHelper offset to the e.clientX/e.clientY of the click. I'd like the helper to start where the thumb is.
After I drop the helper, the original thumb in the gallery div is gone, and dragging has broken so that I can't drag the second image.
I build the newHelper with
function buildHelper (){
$(this).prependTo('#newHelper'); // this keyword is the thumb
return $('#newHelper');
}
Does anyone see what I'm doing wrong?
Thanks
For the buildHelper function to work as expected, it has to return a clone of the original element that you want to drag + clone of #newHelper .
I think there are better solutions to this problem, but for your example this will work;
function buildHelper() {
return $("#newHelper").clone().append($(this).clone());
}
You can view an example of this: http://jsfiddle.net/Rusln/EXQhx/
Hi I am developing a application where I need to display number of images with some conditions. The images should display one by one on the screen when next button is clicked.Here the size of all images is 360x480.When the image is display then all other fields like next and previous buttons should be added to the screen.How to paint those images.Can anybody please help me in this regard.
You can display images with the BitmapField. Use the setBitmap() method to change the image.
Edit: Ok, so you would want to do something like this, put the names of all your bitmaps in an array, have the button's listeners increment or decrement the array index and display that bitmap. So your next button might look like this:
ButtonField nextButton = new ButtonField("Next");
nextButton.setChangeListener(new FieldChangeListener(){
public void fieldChanged(Field field, int context)
{
if(arrayIndex + 1 >= bitmapArray.length)
{
return;
}
arrayIndex++;
Bitmap image = Bitmap.getBitmapResource(bitmapArray[arrayIndex])
myBitmapField.setBitmap(image);
}
});
This assumes that your images are preloaded with your app and are stored in the 'res' directory, if you're downloading them from online or they're stored on the filesystem the way you load the bitmap will be somewhat different. I haven't compiled this code so it may have some bugs but this is roughly what you want to do.
I'm having some trouble finding documentation on CLOSING a blackberry map.
My map opens, albeit with some odd marker behavior, but when you close the map it displays a clear screen.
The invoke code is quite simple, as the map request calls a new controller and within the constructor is this:
String document = "<location-document>... etc";
Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, new MapsArguments( MapsArguments.ARG_LOCATION_DOCUMENT, document));
I tried to add a close line
public boolean onClose() {
UiApplication.getUiApplication().popScreen(this);
return true;
}
but this is not being applied to the map itself, but the page the map opened into. That's logical, I guess.
Maybe I'm going about this all wrong. I don't know of how to open a map another way, or if there is a way to have the close button close the map AND the containing screen.
Any help is appreciated.
I solved this with a simple one line function that fixed this problem.
public void onExposed()
{
UiApplication.getUiApplication().popScreen(this);
}
Adding that to the map controller closes the map application when the user clicks the back button. Simple as that.
I have a tree control that implements drag and drop. I use an overridden OnStartDrag() to get my own TDragObjectEx that shows an image while dragging. This works perfectly within the tree control, but as soon as I leave the tree control the image disappears. The cursor stays though.
I tried implementing OnDragOver, to reset the image but that does not appear to work.
Any hints on this? I am using C++ builder 2010, but delphi would do the same thing.
Update:
Found setting csDisplayDragImage on each control in the form controls, and in form itself solves this issue. Is there some automated way to have csDisplayDragImage set in an entire form rather than have to set it manually in Create for each item?
void __fastcall TForm1::FormCreate(TObject *Sender)
{
ControlStyle << csDisplayDragImage;
RMU->ControlStyle << csDisplayDragImage;
Button1->ControlStyle << csDisplayDragImage;
}
If I remember correct, you have to include the [csDisplayDragImage] flag in the "ControlStyle" of controls of which you want drag images to be seen when sth. is being dragged over them..
Update: setting "AlwaysShowDragImages" of the DragObject causes the drag image to be displayed all across the desktop.
Evidently, each control that's going to display the drag image needs to have the csDisplayDragImage control style set. You can add that flag to a control and all its chilren with a simple function:
void AddDisplayDragImageStyle(TControl* ctl)
{
ctl->ControlStyle << csDisplayDragImage;
TWinControl* win = dynamic_cast<TWinControl*>(ctl);
if (win)
for (int i = 0; i < win->ControlCount; ++i)
AddDisplayDragImageStyle(win->Controls[i]);
}
Have the form call that on itself: AddDisplayDragImageStyle(this).