I am working on a Qt project (Java). I am trying to build a qwebview that allows me to download pdf files from a website.
Here is the code I used:
public Browser() {
this.setDefaultUrl();
this.page().setForwardUnsupportedContent(true);
this.page().unsupportedContent.connect(this,"download()");
}
public void setUrl(String url){
this.load(new QUrl(url));
}
public void setDefaultUrl(){
this.load(new QUrl("http://genome.ucsc.edu/cgi-bin/hgGateway"));
}
public void download(){
System.out.println("Ok");
}
If I click on "We still provide postscript files: browser graphic and ideogram" the signal shoots correctly but if I click on "Download the current browser graphic in PDF" I don't get any signal. Is this because pdf files must be handled differently?
Any ideas why?
Thanks a lot in advance
Related
I am using WebView for loading websites in my project. It is loading websites but very slow. It takes around 10 to 15 seconds to load this site.
I try a solution from this thread. I have added android:hardwareAccelerated="true" on the manifest under application level, but no luck.
For iOS and Windows the solution is below: But I don't know how to create the custom render.
In iOS, try to use WKWebView instead of UIWebView.
For the UWP, use Windows.UI.Xaml.Controls.WebViewcontrol instead of using the built-in Xamarin WebView control.
Can I get the sample custom renderer for iOS and Windows-like above?
It is loading websites but very slow
The speed of loading website will up to lots of causes . For example, it will consume a lot of time if the web contains many remote css/js file . And it will also up to network performance .
The link that you provided loads slow even if on browser on my side . It contains lots of remote css if we check the source code.
For Android , We can create an custom renderer webview to accelerate it.
Set Render Priority to hight.
Enable the dom storeage.
When Loading the html, we can disable the image showing, when
loading finished, load the image by
Control.Settings.BlockNetworkImage.
Enable the Cache, if you load it at the nexttime, you can load it
quickly.
[assembly: ExportRenderer(typeof(Xamarin.Forms.WebView), typeof(MyWebviewRender))]
namespace MyWebviewDemo.Droid
{
public class MyWebviewRender : WebViewRenderer
{
public MyWebviewRender(Context context) : base(context)
{
}
protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.WebView> e)
{
base.OnElementChanged(e);
Control.Settings.JavaScriptEnabled = true;
Control.Settings.SetAppCacheEnabled(true);
Control.Settings.CacheMode = Android.Webkit.CacheModes.Normal;
Control.Settings.SetRenderPriority(RenderPriority.High);
Control.Settings.DomStorageEnabled = true;
Control.Settings.BlockNetworkImage = true;
Control.SetWebChromeClient(new MyWebChromeClient());
}
}
internal class MyWebChromeClient : WebChromeClient
{
public override void OnProgressChanged(Android.Webkit.WebView view, int newProgress)
{
base.OnProgressChanged(view, newProgress);
if (newProgress == 100)
{
// webview load success
// // loadDialog.dismiss();
view.Settings.BlockNetworkImage=false;
}
else
{
// webview loading
// loadDialog.show();
}
}
}
}
In iOS, try to use WKWebView instead of UIWebView. For the UWP, use Windows.UI.Xaml.Controls.WebViewcontrol instead of using the built-in Xamarin WebView control.
In your case it will only have less improve even if using above solution . You could add an ActivityIndicator during the loading . If you can access the website , it would be better to download the css file to local and loading them in ContentPage .
I have a Qt application that loads some file after clicking on button. I am using QFileDialog to open files. Every time I close file dialog, the application main window (QMainWindow) is behind all other opened windows (internet browser, explorer etc.). Is this standard behaviour? And is there any way to prevent this? I tried
// set always on top window
Qt::WindowFlags flags = this->windowFlags();
this->setWindowFlags(flags | Qt::WindowStaysOnTopHint);
but it causes that also file dialog is behind main window.
Edited:
Here is fragment of code to call file dialog (method that calls it is static method of my class LoadData):
void MainWindow::on_buttonIP_clicked()
{
loaded = LoadData::OpenFiles(IPFiles);
}
bool LoadData::openFiles(QStringList &fileNames)
{
// open files dialog
fileNames = QFileDialog::getOpenFileNames(0,
tr("Open files"), "", "Text Files (*.txt *.dat *.points)");
if (fileNames.isEmpty())
{
return false;
}
return true;
}
First argument of QFileDialog::getOpenFileNames must not be nullptr. Set it to your main window, and everything will be OK.
I see this tutorial, and create abstract form tool button. But in RAP I can't configure the icon image.
My tool button is like this :
#Order(10.0)
public class TestPageTool extends AbstractFormToolButton {
#Override
protected String getConfiguredIconId() {
return Icons.EclipseScout;
}
#Override
protected String getConfiguredText() {
return TEXTS.get("TestPage");
}
}
and the result is :
A solution can be found in the widgets demo application (live demo, source, about)
The images are defined twice:
Client (used in the desktop client):
org.eclipsescout.demo.widgets.client/resources/icons/star_red.png
org.eclipsescout.demo.widgets.client/resources/icons/star_red.png
RAP Bundle (used for the RAP client):
org.eclipsescout.demo.widgets.ui.rap/theme/img/button/tool/star_red.png
org.eclipsescout.demo.widgets.ui.rap/theme/img/button/tool/star_yellow.png
In the RAP client, you also need to customize the CSS, to bind the icon defined in the RAP Bundle with the Tool Button. Check the content of application.css to have an example:
org.eclipsescout.demo.widgets.ui.rap/theme/application.css
Hello i am making a web browser in javafx and i want to make it fullscreen when user clicks on Fullscreen button. I tried the below given code but unfortunately it is giving error.
Fullscreen.setOnAction(new EventHandler<ActionEvent>() {
#Override
public void handle(ActionEvent event) {
primaryStage.setFullScreen(true); // here it gives error "cannot find variable primaryStage"
}
});
**I know that this doesn't follow the basics of java but i didn't find another way of implementing it.
Kindly help :)
Assuming Fullscreen is a button, just get the stage it's in with
((Stage)Fullscreen.getScene().getWindow()).setFullScreen(true);
I am trying to add page with custom extension, say .asp2 with my set of html tags.
Now whenever i try to access the page on browser...it asks me "Save as". This happens because I am using an extn which the server is not able to recognise.
What should I do to so that my server, IIS 5.1 recognises this extension??
Please suggest
Also please suggest on how to associate custom events on such custom page?
In Internet Services Manager, right click on Default Web Site, select Properties, in Home Directory press the Configuration button. Click the Add button and fill the Executable field with the path to the aspnet_isapi.dll file and put asp2 in the Extension field.
Using a non-standard extension, you should also be sure to set the response's Content Type to text/html, so the browser knows how to interpret the document you're sending. Something like:
public class HttpHandler1 : IHttpHandler
{
public bool IsReusable
{
get { return true; }
}
public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/html";
// Your code here.
}
}