How to change UITabBarItem position? - uitabbarcontroller

I need to change UITabBarItem's image and text position when it's highlighted. Is it possible?

It's look like there is no way to change UITabBarItem's image's position. I just corrected my selected image to have about 15 pixels in button and corrected UITabBarItem's title's position on 15 in tabBar:didSelectItem: method of my custom UITabBarController:
- (void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item
{
// If there is another selected item set default properties to it.
for (int counter = 0; counter < [self.tabBar.items count]; counter++) {
UITabBarItem *currentSelectedItem = [self.tabBar.items objectAtIndex:counter];
[currentSelectedItem setTitlePositionAdjustment:UIOffsetMake(0, 0)];
}
// Set selected item.
UITabBarItem *selectedItem = item;
[selectedItem setTitlePositionAdjustment:UIOffsetMake(0, -15)];
}

Related

How to stop expansion of QGridLayout element

I have couple of labels (dynamically generated on button click and can vary in numbers which read from configuration file) and added to QGridLayout. Upon load which looks like below ...
these labels are generated and added as below
QGridLayout * layout = new QGridLayout(ui->pageInputWindow);
layout->setSpacing(5);
layout->setMargin(0);
ui->pageInputWindow->setLayout(layout);
// for question purpose I take number of row and col to 3
// but in actual they will be read from configuration file
for(int row = 0; row < 3; row ++)
{
for(int col = 0; col < 3; col++)
{
QLabel * placeHolder = new QLabel(ui->pageInputWindow);
placeHolder->setText("LABEL "+QString::number(10*(row+1) + col + 1));
layout->addWidget(placeHolder, row, col);
}
}
These label are placed here for rendering video streaming by setting pixmap of captured video frames when selected. I am setting pix as ....
// I am getting img object from other class, below code is just a snap of it.
// You can assume img as valid QImage objcet
QImage img
selectedLabel->setPixmap(QPixmap::fromImage(img).scaled(selectedLabel->size(),Qt::KeepAspectRatio, Qt::FastTransformation));
My ideal scenario is when I select any label it will remain with size which it got when loaded according to configuration settings at runtime. But when I start streaming below event happened.
Suddenly selected label ( see black pictured label at 'LABEL 11' position) starts expansding to much even causing application to expand. Idealy I want above event as below ( assume white background is video frame ) without any expansion.
My question is how can I stop this undesirable expansion of labels while setting pix map on them ?
Set the labels' size policies to ignored:
placeHolder->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);

Change bar color depending on value

I'm using chart-js/ng2-charts for an angular 2 app.
I can display a bar graph, but at the moment, all the bars are the same color. I'd like to have a different color depending on the value.
Can that be done?
After you create your chart, you can use the following function to loop through the dataset and change the color depending on the data value.
In this example, if the value is above a 50, the color changes to red.
var colorChangeValue = 50; //set this to whatever is the deciding color change value
var dataset = myChart.data.datasets[0];
for (var i = 0; i < dataset.data.length; i++) {
if (dataset.data[i] > colorChangeValue) {
dataset.backgroundColor[i] = chartColors.red;
}
}
myChart.update();
JSFiddle Demo: https://jsfiddle.net/6d0jsyxu/1/

How to Add Icon in cells of a column CListCtrl

I have a CListCtrl that shows my data in rows. It has two column. Now i need to add another column that will be actually showing a icon.
// set look and feel
listCtrl.SetExtendedStyle(listCtrl.GetExtendedStyle() | columnStyles);
Adding row items as below :
for (const auto dataValue : dataTable)
{
int rowIndex = listCtrl.GetItemCount();
listCtrl.InsertItem(rowIndex, dataValue.at(0).c_str());
for (int colIndex = 1; colIndex < listCtrl.GetHeaderCtrl()->GetItemCount(); ++colIndex)
{
listCtrl.SetItemText(rowIndex, colIndex, dataValue.at(colIndex).c_str());
}
}
I added a new column that will contain the icons for the rows.
I can not getting proper idea how to add icon in the cells of the added column. Consider it's added in first column.
Please suggest.
You don't need a new column, as the image is displayed in the left of the first column (Given your text I assume you are using the LVS_REPORT style).
You need to have a member image list with same count of images as items of your list. So on your list's derived class, add a member:
CImageList m_ImageList;
Then on your list's OnCreate function:
m_ImageList.Create(32, 32, ILC_COLOR24, numberOfEnableParts, 1);
m_ImageList.SetImageCount(n);
for (int i = 0; i< n; i++)
{
if(InsertItem(n, sText) != -1)
{
//set text of columns with SetItemText
//...
// don't know if you use a icon or a bitmap; next line I did it for the second case
m_ImageList->Replace(n, CBitmap::FromHandle(hBmp), (CBitmap*)NULL);
//then, associate the item with its own image of the image list
LVITEM lvi;
lvi.iItem= i;
lvi.iSubItem= 0;
lvi.mask = LVIF_IMAGE;
lvi.iImage= i;
SetItem(&lvi);
}
}
SetImageList(m_ImageList, LVSIL_SMALL);

Qt - How to change a QTextEdit's font size with a QComboBox

im trying to change the font size of a QTextEdit by using a QComboBox which is filled in with different values, so for example when I choose a value in the QComboBox it will change the QTextEdits size to the value I have selected. I have values in the QComboBox but I don't know how to change the QTextEdit's value to the value I have selected.
Below is the code I used to fill the QComboBox with values:
for (int i = 0; i < 102; i+=2){
QStringList list = (QStringList()<<QString::number(i));
ui->combobox->addItem(list);
Any help on what to do from here would be appreciated thank you!
QTextEdit* textEdit = new QTextEdit(......);
QComboBox* fontSizeCombo = new QComboBox(....);
for (int i = 1; i < 102; i += 2) {
fontSizeCombo->addItem(QString::number(i));
}
connect(fontSizeCombo, SIGNAL(currentIndexChanged(QString), SLOT(changeFontSize(QString));
void MyClass::changeFontSize(const QString& selected)
{
textEdit->setFontPointSize(selected.toInt());
}
Don't need appending QStringList with each item.
Don't set font size to 0. Excerpt from the Qt docs:
Note that if s is zero or negative, the behavior of this function is
not defined.

Row Background Color GtkTreeView Widget

I'm attempting to color disabled rows in a gtk tree view widget a light gray color. From what I've read, I'm supposed to set the background-gdk property of the corresponding cellrenderer and bind it to a model column. This sort of works.
Gtk::CellRendererText* textRenderer = manage(new Gtk::CellRendererText());
textRenderer->property_editable() = false;
Gtk::TreeViewColumn *col = manage(new Gtk::TreeViewColumn("Column1", *textRenderer));
col->add_attribute(*textRenderer, "background-gdk", m_treeview_columns.m_back_color);
my_treeview.append_column(*col);
Gtk::TreeModel::Row row;
for (int i = 0; i < NUMBER_OF_ROWS; iLane++){
row = *(treeview_liststore->append());
row[m_workListColumns.m_back_color] = Gdk::Color("#CCCCCC");
}
In the end though, I get only the cells colored properly. BUT I also get an ugly white-space in between the cells. Does anyone know of a way to fix this or a better way to achieve the effect I'm after?
Could you set the background of the row to match the cell background or set the bakground of the tree view all together ? Or maybe the cell with cell-background-gdk ?