in Education by
On my Windows machine text is displayed to the right of the progress bar. On my Linux machine text appears in the middle of the progress bar. If I apply style to progress bar, text appears inside on both systems. How do I get it to appear outside, like in default Windows style? Here's the simplified version of the code I used to play with progress bars: MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { auto widget = new QWidget; auto layout1 = new QVBoxLayout; widget->setLayout(layout1); auto layout2 = new QHBoxLayout; auto progressBar = new QProgressBar; auto spinBox = new QDoubleSpinBox; spinBox->setRange(0,100); spinBox->setDecimals(1); spinBox->setSingleStep(1); progressBar->setRange(0, 10000); connect(spinBox, qOverload(&QDoubleSpinBox::valueChanged), progressBar, [spinBox, progressBar] { progressBar->setValue(spinBox->value() * 100); progressBar->repaint(); }); layout2->addWidget(spinBox); layout2->addWidget(progressBar); auto textEdit = new QPlainTextEdit; auto stylesheet = R"( QProgressBar { background-color: cyan; border-radius: 1px; text-align: right; } QProgressBar::chunk { background-color: magenta; border-radius: 1px; } )"; textEdit->setPlainText(stylesheet); connect(textEdit, &QPlainTextEdit::textChanged, progressBar, [textEdit, progressBar] { progressBar->setStyleSheet(textEdit->toPlainText()); }); layout1->addLayout(layout2); layout1->addWidget(textEdit, 1); setCentralWidget(widget); } JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
The solution is to use a margin. If you change the QProgressBar section of your stylesheet to this: QProgressBar { background-color: cyan; border-radius: 1px; text-align: right; margin-right: 4em; } then the right end of the progress bar will stop short of the text (which is right-aligned), resulting in the effect you are looking for.

Related questions

0 votes
    I want to be able to zoom in my QtCharts using the mouse. The best way to zoom using the mouse ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 6, 2022 in Education by JackTerrance
0 votes
    According to my understanding of QDateEdit's API documentation it creates a widget for editing dates. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 22, 2022 in Education by JackTerrance
0 votes
    According to my understanding of QDateEdit's API documentation it creates a widget for editing dates. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    According to my understanding of QDateEdit's API documentation it creates a widget for editing dates. The ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    As it currently stands, this question is not a good fit for our Q&A format. We expect answers to ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 21, 2022 in Education by JackTerrance
0 votes
    I hope my question isn't always the same question. I have a QGraphicsScene. Its items are some ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 20, 2022 in Education by JackTerrance
0 votes
    I'm working on a mini text role playing game where you must survive dinner with the king. I'm ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 8, 2022 in Education by JackTerrance
0 votes
    I'm maintaining a Windows app that has multiple forms in the one window (form1, form2, form3). I' ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    I've created a library as the module for personal use outside of "GOPATH" in "database" folder with ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I am looking for a way to close a component when there it a click outisde of the element. I ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    I've got an extensive project. Amongst other things, it contains an UserForm Worksheet (Data) with a button ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 19, 2022 in Education by JackTerrance
0 votes
    I made this single web page and when I view it my mobile device, and I thumb to the left, the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    ActiveRecord 3.2.14 I want to use ActiveRecord in a non-Rails Ruby project. I want to have ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 3, 2022 in Education by JackTerrance
0 votes
    I'm learning OpenGL ES for android, but i'm a tiny bit confused. In the examples I've seen the ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 19, 2022 in Education by JackTerrance
0 votes
    Is there an 'official' way to get all input elements of a form including those outside of the form ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 13, 2022 in Education by JackTerrance
...