I know it is possible to call setFixedSize() to widget and it will be "inactive" but i want to know is it possible to hide it at all.
So you can try like this in constructor of MainWindow class:
this->statusBar()->setSizeGripEnabled(false);
Related
We have a custom widget that we want to use as item(cell) widget in QListView. And we don't want to use QListWidget. So is there any way to use our custom widget for a cell in QListView. The delegate seems to have a paint() method , but there is no method from which we can return the custom widget that we want to use for a cell. Can any one please help regarding this? Thanks in advance.
Is it possible to return a handle to the splitters in QMainWindow which separate the dock widgets?
There is some internal class QMainWindowLayout, maybe you can figure out how to get to it if you look into source
I personally don't think you can get handle to it.. I don't know what you want to achieve - the handle can be styled with QMainWindow::separator..
But you can try to use QSplitter which has method QSplitter::handle(index). You can then add some buttons to the handle etc:
button = new QPushButton("<", ui->splitter->handle(1));
handleLayout->addWidget(button);
ui->splitter->handle(1)->setLayout(handleLayout);
I was experimenting with QDockWidget in QSplitter's layout and it was working.
I am overriding the QPlainTextEdit to become a single line edit widget. In other words I want it to look like a QLineEdit but to have the extended functionality of QPlainTextEdit, such as text formatting etc.
My only trouble so far is that I do not know how to pass focus to the next/previous widget when I press Tab/Shift+Tab when the widget derived from QPlainTextEdit is in focus. I have started with overriding keyPressEvent to capture Tab key being pressed, but then what? How to change the focus from the widget?
I can only think of too complicated solutions (such as signalling to the parent that the focus should change, but this seems as stupid overkill). I bet there must be a very simple solution to this problem.
Set the tabChangesFocus property of your QPlainTextEdit object to true by using the QPlainTextEdit::setTabChangesFocus function.
I accepted the answer by thuga which is the simplest way. However I found also another one which might be more generic for widgets that do not have tabChangesFocus property. Override keyPressEvent like this:
def keyPressEvent(self, event):
if event.key() == QtCore.Qt.Key_Tab:
self.parent().focusNextChild()
elif event.key() == QtCore.Qt.Key_Backtab:
self.parent().focusPrevChild()
There are two things you can try:
Create QAction and add it to the widget. Set QShortcut to the action with QKeySequence(Qt::Key_Tab). Connect the action whith slot which changes the focus.
or
Use directly new QShortcut(QKeySequence(Qt::Key_Tab), widgetPtr, SLOT(changeFocus()));
So there is no need now to inherit your control only to capture keyPressEvent. Note that you may need to change the shortcut context for best match to your requirements.
I think i'm having a fairly basic Qt problem, but i can't figure it out:
I have a QMainWindow which holds a QStackedWidget. All page widgets in there are seperate classes derived from QWidget.
So:
QMainWindow implements QStacked Window in one class.
All other pages inside the stacked widget are added classes and all have there own .ui filled with buttons and lists trough the Designer.
For navigating to different pages, inside the Mainwindow i have access to: ui.stackedWidget->setCurrentIndex(2);
It seems i don't have access to ui.stackedWidget on another page inside the stacked widget? I have no access to the ui.stackedWidget because Ui is a private member in the mainwindow class. (auto generated by Qt - using VS addon for adding QT4 classes)
I would like to know, how can i jump to another page in the stacked widget, when clicking on a button that belongs to another page inside this widget?
Note:
All pages are added to the StackedWidget in mainWIndow's constructor:
ui.stackedWidget->addWidget(page1Widget);
ui.stackedWidget->addWidget(page2Widget);
// etc..
Example of a button click signal-slot inside page1Widget:
connect(ui.btnViewData, SIGNAL(clicked()), this, SLOT(viewData()));
::viewData()
{
// navigate to another page here.
// note: ui.stackedWidget->setCurrentIndex(3); is not accessible here!
}
I believe that putting your connect() and viewData() functions within your QMainWindow object will solve your problem, since the main window can have access to both the signals emited by the child widgets and the QStackedWidget items.
You might need to write a Ui getter for each of your page, and then do something like
connect(page1Widget->getUi().btnViewData, SIGNAL(clicked()), this, SLOT(viewData)));
hope it helps,
cheers
I have a widget container I wish to manually paint.
However, it is located within my GUI's MainWindow class.
Is there any way I can register on the paint event for a specific QWidget, so my own function will be called ?
Look for eventFilter. It will help you
The most straightforward way would be to override the paintEvent on the widget
you would like to draw in a custom subclass, and then use that class in your GUI.