How change the default title of a web page using QWebView - c++

I am displaying a web page using the below code. But the title always shows as our company name(XYZ).
QString msg;
QWebView view = new QWebView();
view->page()->mainFrame()->setHtml(msg);
view->show();

The QWebView title property seems read-only, and can only be set by using/changing a title tag in the HTML document.
However, the title of the window that pops up when the above code is run can be changed with view->setWindowTitle(), like with any Qt widget which is used as a toplevel window.

Related

How to set modal dialog title dynamically in oracle apex 18

I want to set modal dialog title dynamically based on an interactive element.
ex) In page 50, I've made an Interactive Grid and set the link on "Title" column, when user click on title column, a modal dialog appears.
I want to set the title of that modal dialog to title column's content.
But modal dialog's title doesn't change dynamically.
In this case, how can I apply the titles dynamically?
I've seen many solution related to this question, but I can't solve my problem.
Let's say, your model page number is 51. Here are step by step approach [TESTED] to dynamically change title of model page:
Create a hidden item in your model page, let's say the hidden item name is P51_Title.
In Interactive report -> title column link -> click on link builder box -> set values -> add Hidden item as P51_TITLE under Name and value as '#Title#' Column (#ColumnName#).
In model page 51 static region header (title property), add hidden item value as &P51_TITLE. (dot is mandatory to add at last. This is substitution string with & and dot(.) before and after of item name respectively)
save both the pages and run. when you will click on title column link, the link will be redirecting to the model page and title data will be passed through URL to hidden item in the session, so model page header will automatically change based on title data from report.
I made such dialogcreate js function.
It moves popup page Title to modal dialog title.
So, dynamic calculated title &P51_TITLE. would be applied automatically.
$(document).on("dialogcreate", ".ui-dialog--apex", function(e) {
var lDialog = $(this);
lDialog.find('iframe').on('load',function () {
lDialog.children(".ui-dialog-content")
.dialog("option", "title", $(this.contentDocument).find('title').html());
});
});
I am very disappointed that something like this (or any other solution) do not work in apex modal pages by default!

How to remove focus from MyGUI Widget?

I have a MyGUI::ButtonPtr and on click of this widget I am showing a QWidget. By default focus is on QWdiget but it seems that MyGUI widget also has focus which is creating few issues for me.
myButton = widPtr.at(0)->findWidget("settings")->castType<MyGUI::Button>();
myButton->eventMouseButtonClick += MyGUI::newDelegate(this, settingsClicked);
addToolTip(myButton, "Tooltip text");
void addToolTip(MyGUI::Widget *widget, QString toolTipLabel)
{
widget->eventToolTip += MyGUI::newDelegate(this, notifyTooltipEvent);
widget->setNeedToolTip(true);
widget->setUserString("tooltip", toolTipLabel.toStdString());
}
This tooltip should only be displayed on mouseover but it is visible also when button is clicked and QWidget is open which is incorrect. Reason for this seems to me that MyGUI button still has focus due to which tooltip is being displayed. I wish to remove this focus from MyGUI button.
This worked for me.
MyGUI::InputManager::getInstancePtr()->injectMouseRelease(0, 0, MyGUI::MouseButton::Button0);

How to add a CSS Style Class to a QWidget

In JavaFx I can easily add a CSS style class as follows:
Scene scene = new Scene(new Group(), 500, 400);
scene.getStylesheets().add("path/stylesheet.css");
......
Label label = new Label("Cool Looking Styled Label");
label.getStyleClass().add("my-label-style");
css
.my-label-style {
-fx-font: 16px "Serif";
-fx-padding: 10;
-fx-background-color: #CCFF99;
}
How can I go about adding a style class to a QWidget, QLabel, for example?
label->setProperty("class", "my-label-style");
Then in a CSS you can call it normally by:
.my-label-style {
[..]
}
The method is in the QWidget base class; it's QWidget::setStyleSheet.
you have two ways to do that
coding
widget.setStyleSheet("css code");
Form ui
right click on the widget
select change stylesheet
a dialog box appears where you need to write css codes
but all css code are not supported ,you need to see documentation of stylesheet

QLabel & QComboBox setFont does NOT work

I'm using Qt Framework to build an App supporting multiple languages.
The default font is loaded from StyleSheet.
I override paintEvent() method, and setFont() method works OK for all widgets except for QLabel and QComboBox.
For QComboBox, the selected item has the correct font, the but the dropdown list items are using the default font. The Qt manual says setFont will set the font for both the comboBox button and the comboBox popup list to font.
Anyone happens to see this problem and have an idea to fix that? Thanks.
Answer is so long, because I wrote different approaches, choose the best for you.
Try to do next:
Create QListView, customize it (with stylesheet for example)
Set model with your data and set view to QComboBox with special methods:
setModel() and setView()
http://qt-project.org/doc/qt-4.8/qcombobox.html#setView
setStyleSheet("font-family: Arial;font-style: normal;font-size: 12pt");
For label you can use stylesheet too, setFont or just set HTML code with suitable font:
QFont f( "Arial", 14, QFont::Bold);
label->setFont(f);
With ComboBox you can use this for example:
QStringList stringList;
stringList << "#hello" << "#quit" << "#bye";
QStringListModel *mdl = new QStringListModel(stringList);
QFont comboFont("Arial",16,-1,true);
QListView *vw = new QListView;
vw->setFont(comboFont);
ui->comboBox->setModel(mdl);
ui->comboBox->setView(vw);
But it will install font to your data in popup menu, not in the header, so you can use also next:
QFont comboFont("Arial",16,-1,true);
for(int i = 0; i< ui->comboBox->count(); i++)
{
ui->comboBox->setItemData(i,QVariant(comboFont),Qt::FontRole);
}
ui->comboBox->setFont(comboFont);
Wityh this code snippet you'll get popup menu and header with this font and you don't need create models and views.
My dear, it is enough to do hereunder:
ui->CboxOpisBaza->lineEdit()->setFont(QFont("MS Shell Dlg 2", 12));

Internal QWidgets of QTabBar's tab?

As a follow up of " Hide label text for Qt tabs without setting text to empty string " :
Can I directly access the widgets within the tabs of the QTabBar. I do not mean the corresponding widget which is shown when I select a tab, but the tab's widgets (so in the screenshot below the log label and log icon).
I have tried QTabBar::findChildren, but with no success. Any idea?
QTabBar header sections are not actually widgets. They are drawn by QStylePainter inside QTabBar::paintEvent. Thus you can't get access to them.
As a workaround you can add a tab with an empty text and set a custom widget to it:
QTabBar *bar = new QTabBar;
bar->addTab("");
QLabel *label = new QLabel("my label");
bar->setTabButton(0, QTabBar::LeftSide, label);