How to show cellWidget of QTableWidget only when clicking? - qt

I don't want all cellWidgets to show all the time. I want them only to show when user double clicks the cell.

When you add a widget to the cell hide it immediately hide
after user double clicks the cell use cellDoubleClicked signal to show cell widget

Related

How to make a button when pressed to do a certain thing on another screen Appinventor

I would like a button when pressed to do a certain thing on another screen. For example if I had 2 buttons on screen1, and when you click either of the buttons it opens another screen, however depending on which button clicked it will display a certain component.
You can use these two blocks to do that. When two buttons are pressed, they both open the same screen, but they have different start values. Then, on the other screen, you can use the get start value block to find out what value you got, to figure out which button was pressed.
Solution 1:
You can use two separate activities for separate components.
or
Solution 2:
Pass your button position as putExtra from first screen.
Intent i=new Intent(getApplicationContext(), NextActivity.class);
i.putExtra("btn_position",position); //pass your button positon as int
startActivity(i);
And get the your button position using getExtra from second screen.
Intent intent = getIntent();
int button_postion = intent.getIntExtra("position", 0);

Custom popup in JavaFX

Is there any way to create a custom PopUp in JavaFX? I can't use tooltip, since I would like it to appear on double click, also I would like a different style than the standard tooltip.
My demands for the popup are:
1. If the user double click, show the popup
2. if the user clicks outside the popup, hide it
See this guide on all the different types of popups.
Use Popup.
Popup popup = new Popup();
// add content (you can add as many nodes as you want)
popup.getContent().add(new Label("Hello Popup!"));
// show (move this to the double-click listener)
popup.show(primaryStage);
// hide (move this to the click listener)
popup.hide();

Whenever a cell in QTableView is selected, an unrelated QPushButton gains focus along with the cell

I have a QTabWidget, that on a particular tab holds a QTableView subclass and a QHBoxLayout of QPushButtons (Insert, Delete, Fill/Calc, Copy, Paste).
The red circles show that whenever I make a selection in the QTableView, the Insert button also gains selection.
As a result, when the user types into the Segment Name line edit and hits enter (to submit the changes), the changes are submitted and the insert button is activated.
What can I do to make the QTableView cells and the Insert button mutually exclusive for selection?
In other words, when a user clicks on a table cell I do not want any buttons selected.
It seems that your button is default.
Change it to false.
ui->insertButton->setDefault(false);
http://doc.qt.io/qt-4.8/qpushbutton.html#default-prop
http://doc.qt.io/qt-4.8/qpushbutton.html#autoDefault-prop

Let QTabWidget switch to corresponding page when mouse cursor hover on the tab

I want to show the corresponding page when mouse cursor hover on the tab of a QTabWidget.
For example, when the mouse cursor hover on tab ‘page2’ here , I hope the QTabWidget shows the corresponding page automatically instead of clicking. How to implement this feature?
You may try adding an event filter on the QTabWidget object's QTabBar in order to trap the mouse move event. In the filter handler, use QTabBar::tabAt( QPoint ) to find which tab is below the cursor. Set up a timer when the cursor first enters a given tab, reset time when cursor leaves it. When the timer fires, switch active tabs.
You may try using setTabToolTop function.
ui->tabWidgetHz->setTabToolTip(0,"tooltip for tab1.");
ui->tabWidgetHz->setTabToolTip(1,"tooltip for tab2.");
ui->tabWidgetHz->setTabToolTip(2,"tooltip for tab3");

Qt:creating a dynamic button

I want to create an application in which i will create a button and by pressing that button as list of options will open and i can choose one of them.for example i will create a button named "searching algorithm" and by clicking this button a list will open at same place which display two options as linear search and binary search.can anyone give me an idea how to do that?
You want a QComboBox:
The QComboBox widget is a combined button and popup list.
I believe what you need is a popup window where you can have list of options, whenever your button is clicked show this window, hide it when user selects an item in the list or clicks outside of the working area. There is an example you can use as a reference:
QT 4.7 Google Suggest Example
hope this helps,
regards

Resources