Is there equivalent to QT's chooseFile()/setPage()?

Having problems with building or using CEF's C/C++ APIs? This forum is here to help. Please do not post bug reports or feature requests here.

Is there equivalent to QT's chooseFile()/setPage()?

Postby AssemblyMan » Thu Sep 03, 2015 9:40 pm

I'm new to CEF, I'm porting some QT C++ classes where I call chooseFile() and setPage(). Are there equivalents to it in CEF? if didn't, is there any way I can archive the chooseFile()/setPage()'s behavior?
AssemblyMan
Newbie
 
Posts: 2
Joined: Thu Sep 03, 2015 9:31 pm

Re: Is there equivalent to QT's chooseFile()/setPage()?

Postby amaitland » Fri Sep 04, 2015 3:17 am

Perhaps describing what your trying to achieve rather than hoping someone is familiar with both frameworks will get you a more concise answer?

apidocs3/projects/%28default%29/CefDownloadHandler.html

Searching through the API is pretty helpful (even though it's slightly out of date).
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1291
Joined: Wed Jan 14, 2015 2:35 am

Re: Is there equivalent to QT's chooseFile()/setPage()?

Postby AssemblyMan » Fri Sep 04, 2015 12:47 pm

Hello amaitland , I'm sorry for not proveding enough information. I was looking for somone point me the functions so that I could do the implementation myself.

Here's some piece of code I'm trying to port:

webpage.h

Code: Select all
class webpage : public QWebPage
#ifndef WEBPAGE_H
#define WEBPAGE_H

#include <QWebView>

class webpage : public QWebPage
{
public:
    webpage(QObject* parent = 0);
    virtual QString chooseFile(QWebFrame *originatinFrame, const QString & oldFile);
    void setUploadFile(const QString selector, const QString filename);
    QString overrideUpload;
};
#endif // WEBPAGE_H


webpage.cpp

Code: Select all
#include "webpage.h"
#include <QString>
#include <QWebElement>
#include <QWebFrame>
#include <QEvent>
#include <QKeyEvent>

webpage::webpage(QObject *parent)
    : QWebPage(parent)
{

}

QString webpage::chooseFile(QWebFrame *originatinFrame, const QString &oldFile)
{
    return overrideUpload;
}

void webpage::setUploadFile(const QString selector, const QString filename)
{
    QWebElement button = mainFrame()->documentElement().findFirst(selector);
    overrideUpload = filename;
    button.setFocus();
    QKeyEvent keyEvent(QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
    webpage::event(&keyEvent);
}
Last edited by AssemblyMan on Sat Sep 05, 2015 5:22 pm, edited 1 time in total.
AssemblyMan
Newbie
 
Posts: 2
Joined: Thu Sep 03, 2015 9:31 pm

Re: Is there equivalent to QT's chooseFile()/setPage()?

Postby amaitland » Fri Sep 04, 2015 5:06 pm

`cefclient` is the reference application, demos a lot of features.

https://bitbucket.org/chromiumembedded/ ... ?at=master

What exactly does set page do? CEF has no abstraction for a page, so I'm not sure what your trying to achieve exactly.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1291
Joined: Wed Jan 14, 2015 2:35 am


Return to Support Forum

Who is online

Users browsing this forum: No registered users and 23 guests