I've been searching the Qt docs for something similar to a GtkSpinner, but found only the possibility to use a QProgressBar with minimum and maximum both set to 0, which however is not what I want.
Is there such a widget in Qt?
QLabel label;
QMovie * movie = new QMovie("animated.gif");
label.setMovie(movie);
movie->start();
As seen in spinner (delay) button thread on QtCentre
Related
I am using Qt6 to create a cross-platform GUI application. I am playing around with the automatically generated QMenuBar object in Designer Mode. I want to change the QMenuBar items (File, Edit, Help.. ) to bold and red.
I am using the following code in the StyleSheet editor of the MainWindow object:
QMenuBar::item:selected {
font:bold;
color:red;
}
The code works fine for changing the color of the text but it does not set the font to "bold" as I would like. Also, trying to change the font size does not work.
What am I missing?
Thank you in advance!!
QMenubar does not have a font, you need to give the font separately to QAction. I think this will solve the problem
QMenu *fileMenu ;
QAction *newAct = new QAction(tr("&New"), this);
QFont f = newAct->font();
f.setBold(true);
newAct->setFont(f);
fileMenu = menuBar()->addMenu(tr("&File"));
fileMenu->addAction(newAct);
but if you want an active QAction then you need to
setStyleSheet("QMenu::item:selected {font: bold;}");
I want to have one or more QPushButtons or other widgets on top of Qt3DWidget, but it is invisible. Don't know why.
In my mainwindow.cpp I have such code:
this->renderer = new Qt3DExtras::Qt3DWindow();
this->renderer->defaultFrameGraph()->setClearColor(QColor(QRgb(0x4d4d41));
this->rendererContainer = QWidget::createWindowContainer(this->renderer);
ui->centralWidget->layout()->addWidget(this->rendererContainer);
this->shotButton = new QPushButton("Make photo", this->rendererContainer);
this->shotButton->move(this->rendererContainer->width() / 2 - (this->shotButton->width()-20) / 2, this->rendererContainer->height()-40);
It worked when I tried to use QOpenGLWidget, but with Qt3DWindow this button is always invisible. Looks like Qt3DWindow draws on top of it.
I found the reason, but I can't say that I found the solution. The widget, provided by 'createWindowContainer', is drawing on top of everything of the parent window, according to docs. Every single widget in the same position with it will be under it and invisible for user.
The only way which I found to put something on top of Qt3D is to write an app by using QtQuick and QScene3D.
I need to create a customized and animated loading screen in Qt, and I don't need a progress bar.
I want to do something like this:
Anyone knows how can I do that?
Can I use, for example, QSplashScreen?
Try QMovie to load an animation`
QMovie * movie = new QMovie("http://i.stack.imgur.com/vdYAH.gif");
You can either load the movie directly to a label, hide and show it when necessary
QLabel label;
label.setMovie(movie);
movie->start();
Or read the frames of the movie to set splash screen pixmap continuously
connect(movie, SIGNAL(frameChanged(int)), this, SLOT(setSplashScreenPixmap(int)));
movie->start();
I'm looking for the simpliest way, using Qt Designer and a little code, to drag text from a QListWidget (apparently there are options of draggable content in Qt Designer) to a QLabel (but I can't find any droppable action option ...) so its text is set to the text of the item we dragged.
Any ideas ?
[C++, Windows, Qt5]
Well, yeah, the most straightforward idea is subclassing QLabel and reimplementing it's
void dropEvent(QDropEvent* event)
QDrag object will help you pass text from QListWidget via it's mimeData, just create one in mouse event handler.
Check similar questions or examples for more information.
I am using calculatorform example as my base. I have a pushbutton in the same window that opens to a new window. now i want the sum to be displayed in the new window and not the main window.
Is there anyone who has any idea about how to do this? Thanks for any suggestions
Connect the value changed of the output label to the set text of the label in the new window. If you haven't already, I suggest you explore Signals & Slots it explains the concepts quite well. QLabel docs would probably be of help too.