I have a similar question as asked in How to know if QListWidgetItem is hidden by scroll? and the answer to that question didn't fix my problem.
Basically I have a QScrollArea having QGridLayout. This layout has many QToolButtons. Based on some condition, all these QToolButtons need to be updated. To update all of them always is not so efficient, so I want to update only the buttons which are visible in the current active window. How can I achieve this? isVisible() doesn't help here.
Thanks in advance!
You can use QWidget::visibleRegion() to check whether widget is visible and paint events can occur for widget.
if (!button->visibleRegion().isEmpty())
{
//button is visible
}
Related
I need to access currently visible rows (first, last) from a JavaScript function, that is defined inside a TableView.
TableView
{
function getVisibleRows()
{
...
}
}
I see that ListView (what is a Flickable) has a contentY property which would make the problem trivial, but TableView has not. Also, TableView is implemented in terms of a ListView, so there is a ListView involved, but I am not sure how to access it.
Thank You!
I've figured out. I simply need to access flickableItem.contentY.
Use the viewport property of Scrollview (inherited by TableView), which
determines the current "window" on the contentItem. In other words, it
clips it and the size of the viewport tells you how much of the
content area is visible.
viewport return a complete qml item so you can get a lot of position data.
First of all, I'm fairly new with Qt and Qt Creator so go easy if this is a stupid question.
I was practicing using Qt Creator, playing around with css styles. In particular, I'm trying to get the menubar and its menus to look something like this (on Windows): http://i.stack.imgur.com/9lMnQ.png.
However, the closest I've been able to get so far is this: http://i.stack.imgur.com/5Nlen.png.
I've searched online to see if anyone has tried something like this but I wasn't able to find anything.
The only possible solution I can think of is if the menubar item (with no bottom border) could be rendered in above the menu, so that they overlap, covering its top border over the width that they overlap.
If that won't work or is impossible or whatever please do suggest any other solutions/workarounds/hacks.
Thanks in advance!
I think that the only good solution is to avoid any tricks and create a new widget:
Create a new class inherited from QWidget with Qt::Popup attribute.
Place a QMenu into a layout of the widget.
Get a position of QMenuBar item which is clicked using QMenuBar::getActionGeometry.
Calculate position of the widget and of the tab in the widget to be placed over the menubar item.
Customize form of the widget using QWidget::setMask to make it look like a rectangle with a tab.
Show your widget instead of QMenu.
I have a problem when the resize function, I do this in the click signal:
if(ShowingDetails){
ui->BtShowingData->setText("<< Hide details");
//this->setMaximumWidth(1050);
//this->setMinimumWidth(1050);
this->resize(1050, height());
}else {
ui->BtShowingData->setText("Show details >>");
//this->setMaximumWidth(750);
//this->setMinimumWidth(750);
this->resize(750, height());
}
The resize method does its work, but I have two QTableView (with filtering) and when the windows grows up, the Tables are painted black, if I click on them, return to normal. I used ui->TbViewDatosNewAlum->repaint(); but nothing happend. If I update the QSqlTableModel, it's not painted black, but I can't do this. Thanks for your time.
I had the same problem and I found a temporary solution. Hope this helps
Before doing resizing job hide the QTableWidget or QTableView:
tableWidget->hide();
After finishing resizing, show the QTableWidget or QTableView:
tableWidget->show();
It may cause flickering in old systems........but I don't think any system is that old. :)
I add a layout in a dialog and sometimes I want it and all its containing widgets to hide. How to implement it? I try layout->setEnable(false), but it doesn't seem to work in my tests.
You can't do that. You should add a widget in your form, put children inside the widget and assign desired layout to the widget. The behavior will be generally the same, but you can use setVisible or hide methods of the widget.
Transform QLayout to QWidget first, then you can use QWidget->hide().
Is it possible to have individual indentation of items in a QTreeWidget?
In specific, I have have a column containing both text, icon and for some of them a CheckBox. The items without a CheckBox gets shifted to the left so the indentation of the icon and the text is not inline with the others. Could maybe be fixed with a hidden CheckBox if that is possible?
Maybe the use of Delegates will give you a nice and proper implementation. You'll have the opportunity to re-implement the paint() and sizeHint() methods, and therefore, choose the way your QTreeWidgetItem are being drawn...
More documentation here : http://doc.trolltech.com/4.6/model-view-delegate.html
An example : http://doc.trolltech.com/4.6/itemviews-pixelator.html
Hope it helps a bit !
You can try using the QWidget::setContentMargins() on the widget returned by QTreeWidget::itemWidget().