Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 5 years ago.
Improve this question
I have a combobox that holds a list of different command types. I want to change the visible input fields on my GUI depending on the selected command in the combobox. I am very new to Qt, and I would appreciate it if someone could point me in the right direction to implementing this.
My current idea is to have a "select" button that emits a signal, and the connected slot will grab the current index of the combobox. I THINK I need to implement a custom class to hold a QFrame. The custom class will hold slots that indicate which data inputs (for the selected command) should be displayed in the QFrame.
IE, if COMMAND_1 is selected in the combobox, 3 input fields display in the QFrame. If COMMAND_2 is selected, a pair of radio buttons is displayed in the QFrame, and those 3 input fields are hidden or deallocated.
Is this a good way of attempting to solve this problem?
You're going about it the right way. But Qt actually makes it even easier than what you're thinking.
You can use two built-in widgets: QComboBox and QStackedWidget. You're familiar with the combo box; the stacked widget is a set of widgets, of which only one will be displayed at a time. It's essentially a tabbed widget minus the tabs.
Set up your stacked widget so that its first widget is what you want to show when your combo box is showing its first option, the second for the second, and so on. Then you can connect a built-in signal to a built-in slot: QComboBox::currentIndexChanged(int) to QStackedWidget::setCurrentIndex(int).
Hope that helps!
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I am a Visual Studio MFC newbie, and have been a bit perplexed by a problem over the last couple of days. When I create a radio button and assign it variable, I get a "Debug Assertion Failed". How should I make the radio button a variable?
You have to make sure that the first radio button in a sequence of radio buttons is of style WS_GROUP. It is a style you can set in the dialog editor by selecting the first radio button and setting its style to Group.
You want to use an int as the type to receive/set and only use DDX_Radio() on the first radio button on the group. It will return 0 if first radio selected, 1 if second, 2 if third, etc... Make sure the value you use, a member variable is initially set to 0 or another valid value.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
I have link on ID column, when user click on link there is an EDIT button.
When click on EDIT user can make changes.
But, I want to ensure that two users can't edit in same time, and when one user click on edit that all users can't see edit button till save/commit record.
Also to leave message eg. Record is editing by another user, please try later.
I can add one column in table eg. editing number(1), but how to change this column to 1.
when user click on EDIT button?
To give an answer on you question:
You can create a dynamic action which will be triggered on pageLoad. That DA should then update the column to 1 or Y.
!! Warning:
But how will you make sure, that the column will be updated back to 0 or N? Buttons and actions which closes the modal, can update the column back to its initial state, but the X - Close Window button won't. And what if your browser closes or crashes?
In that case, you would be left with a record, which can't be edited anymore by anyone, since that record is still indicated as currently being edited.
I strongly advise not to go down that road!
Instead, trust Oracle APEX's Prevent Lost Updates and Lock Row mechanism's. These are available in the Settings part of the Automatic Row Processing process.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
I want to create custom widget with ui form, but if I add ui form to the widget, it is not showing when building widget.
Shortly, I want to add one button and one textedit into a ui form, and create a custom widget with that, is there an example like this, or how do I do it?
It is very simple to create your custom widget and add it to your ui form. Just follow this:
1- Create a default Qt Widgets Project width ui form.
2- Right click on youe project in Projects window and click 'Add New'
3- Select 'C++ Class' and click 'Choose...'
4- Enter your custom widget name and select "QWidget" as "Base class" and click "Next' and then 'Finish'.
5- In the form editor, add a Widget to the form and then right click on it.
6- From the popup menu , select "Promote to..."
7- In dialog that is displayed, enter your custom widget name in the "promoted class name" field and click add.
8- Select custom widget from list and click "promote"
I have a QTabWidget with several tabs, every tab containing a QTableWidget with numbers. Outside of this QTabWidget, I have one button. When the button is pressed, the currently selected widget should be processed. The QTableWidgets are identical in their structure, they just display numbers, and if I have a pointer to one of these widgets, I cannot deduce which tab it came from.
A simple method to identify which widget is currently selected is to call currentIndex(). But this will break when I reorder the tabs in the designer and is probably not working with movable tabs.
Another way is to use currentIndex() and tabText(int index). Like this I have a stable way to find out which tab is currently selected. The disadvantage of this is that I am then dependent on having unique tab texts, and I in general don't like to rely on a UI property to implement functionality.
My solution for now is to give every Widget a different accessible name that I can then read out like this:
QWidget* widget = tabWidget->currentWidget();
QString* name = widget->accessibleName();
This works, but I wonder if there is a better solution, something like the Qt::UserRole that can be assigned to any cell in a QTableWidget.
I have a QTreeWidget and I want children of a QTreeWidgetItem not indent when I expand them. I want to set the line only for top items. The first screenshot demonstrates what I would like to have, and the second what I am currently having. Would you please help me with how to change it to be like the first one? Thank you in advance!
This is not possible by QTreeWidget since you can only set the indentation globally. You would need to create your own class implementing this logic, e.g. QListWidgets connected to each other, or just a brand new tree widget implementation. You could also of course improve the existing QTreeWidget and send a patch.