Results 1 to 5 of 5

Thread: How to Promote QWebview (Custom widget)

  1. #1
    Join Date
    Apr 2010
    Posts
    22
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default How to Promote QWebview (Custom widget)

    Hi,

    I'm trying to recreate these tutorials:
    http://labs.qt.nokia.com/2008/07/03/...h-google-maps/
    http://efforts.embedded.ufcg.edu.br/qt/?p=80

    There is one thing I cant understand, how to promote QWebview.

    I make identical class, project file, I only make custom Ui. but then I add QWebView to Ui, I can't promote it. Do I need edit mainwindow.ui manually ? as far as I know, this file is generated automatically by Qt Gui designer.
    For example, I create Header file map.h (I will add functionality later)
    Qt Code:
    1. #ifndef MAP_H
    2. #define MAP_H
    3. #include <QWebView>
    4. class map : public QWebView
    5. {
    6. Q_OBJECT
    7. public:
    8. explicit map(QWidget *parent = 0);
    9. signals:
    10. public slots:
    11. };
    12. #endif // MAP_H
    To copy to clipboard, switch view to plain text mode 
    and source file map.cpp with class
    Qt Code:
    1. #include "map.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. map::map(QWidget *parent) :
    5. QWebView(parent)
    6. {
    7. }
    To copy to clipboard, switch view to plain text mode 

    then in UI designer "mainwindow.ui" I add QWebview Widget, Reneame Object name to "map", then I click on it right mouse button, but I can't see "Promote to" option.

    other project files
    mainwindow.h
    Qt Code:
    1. #ifndef MAINWINDOW_H
    2. #define MAINWINDOW_H
    3. #include <QMainWindow>
    4. namespace Ui {
    5. class MainWindow;
    6. }
    7. class MainWindow : public QMainWindow
    8. {
    9. Q_OBJECT
    10. public:
    11. explicit MainWindow(QWidget *parent = 0);
    12. ~MainWindow();
    13. private:
    14. Ui::MainWindow *ui;
    15. };
    16.  
    17. #endif // MAINWINDOW_H
    To copy to clipboard, switch view to plain text mode 

    mainwindow.cpp
    Qt Code:
    1. #include "mainwindow.h"
    2. #include "ui_mainwindow.h"
    3.  
    4. MainWindow::MainWindow(QWidget *parent) :
    5. QMainWindow(parent),
    6. ui(new Ui::MainWindow)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. MainWindow::~MainWindow()
    12. {
    13. delete ui;
    14. }
    To copy to clipboard, switch view to plain text mode 
    untitled1.pro
    Qt Code:
    1. QT += core gui
    2.  
    3. TARGET = untitled1
    4. TEMPLATE = app
    5.  
    6.  
    7. SOURCES += main.cpp\
    8. mainwindow.cpp \
    9. map.cpp
    10.  
    11. HEADERS += mainwindow.h \
    12. map.h
    13.  
    14. FORMS += mainwindow.ui
    15. QT+= network \
    16. xml\
    17. webkit
    To copy to clipboard, switch view to plain text mode 

    If I try to add promoted widget manually from menu "Promoted widgets..." in drop box "base class name:" I cant see QWebView

    Thank you in advice.
    Last edited by Tadas; 18th September 2010 at 14:12.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Promote QWebview (Custom widget)

    It seems QWebView cannot be promoted with Designer.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2010
    Posts
    22
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to Promote QWebview (Custom widget)

    hi wysota,

    but in these tutorials:
    http://labs.qt.nokia.com/2008/07/03/...h-google-maps/
    http://efforts.embedded.ufcg.edu.br/qt/?p=80
    It is done, so there is some way. Both tutorials use Qt designer to develop ui.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to Promote QWebview (Custom widget)

    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. The following user says thank you to wysota for this useful post:

    Tadas (19th September 2010)

  6. #5
    Join Date
    Apr 2010
    Posts
    22
    Thanks
    8
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60

    Default Re: How to Promote QWebview (Custom widget) Solved

    Thank you wysota,

    That was my mistake, I could not find this link, but I have searched and tired many things, but never mind. Thank you for your time and answer.

    I have changed wit text editor "mainwindow.ui" like below:

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
    <class>MainWindow</class>
    <widget class="QMainWindow" name="MainWindow">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>300</height>
    </rect>
    </property>
    <property name="windowTitle">
    <string>MainWindow</string>
    </property>
    <widget class="QWidget" name="centralWidget">
    <widget class="QWebView" name="webView">
    <property name="geometry">
    <rect>
    <x>80</x>
    <y>10</y>
    <width>300</width>
    <height>200</height>
    </rect>
    </property>
    <property name="url">
    <url>
    <string>about:blank</string>
    </url>
    </property>
    </widget>
    </widget>
    <widget class="QMenuBar" name="menuBar">
    <property name="geometry">
    <rect>
    <x>0</x>
    <y>0</y>
    <width>400</width>
    <height>20</height>
    </rect>
    </property>
    </widget>
    <widget class="QToolBar" name="mainToolBar">
    <attribute name="toolBarArea">
    <enum>TopToolBarArea</enum>
    </attribute>
    <attribute name="toolBarBreak">
    <bool>false</bool>
    </attribute>
    </widget>
    <widget class="QStatusBar" name="statusBar"/>
    </widget>
    <layoutdefault spacing="6" margin="11"/>
    <customwidgets>
    <customwidget>
    <class>QWebView</class>
    <extends>QWidget</extends>
    <header>QtWebKit/QWebView</header>
    </customwidget>
    <customwidget>
    <class>map</class>
    <extends>QWebView</extends>
    <header>map.h</header>
    </customwidget>

    </customwidgets>
    <resources/>
    <connections/>
    </ui>


    then I opened project with Qt Creator again, and I was able to promote QWebview.

Similar Threads

  1. code for promote to
    By andreime in forum Qt Programming
    Replies: 2
    Last Post: 15th July 2009, 15:18
  2. how to promote layout in Designer?
    By homerli in forum Qt Tools
    Replies: 1
    Last Post: 11th May 2009, 16:40
  3. promote to...
    By uygar in forum Qt Programming
    Replies: 1
    Last Post: 11th October 2007, 09:07
  4. How Could I promote Qt's Drawing performance?
    By joeshow in forum Qt Programming
    Replies: 5
    Last Post: 11th September 2007, 18:04
  5. promote the contents of a dockwidget!
    By notsonerdysunny in forum Qt Tools
    Replies: 1
    Last Post: 30th July 2007, 05:17

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.