Results 1 to 7 of 7

Thread: Overlapping text in QStatusBar

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Overlapping text in QStatusBar

    I see.
    Well, the current behavior is due to the fact that the QStatusBar has a layout inside it.
    But you want it with a fixed minimum (the minimum being the combined length of all the displayed information in it).
    I would therefore try to set a minimum width to the status bar.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  2. #2
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Overlapping text in QStatusBar

    Unfortunately does not solve the problem.

    The proposed solution limits the minimum width of the whole application plus I do not see this hiding-of-text-on-resizing-application (as it works on native windows apps).

  3. #3
    Join Date
    Jan 2006
    Location
    Munich, Germany
    Posts
    4,714
    Thanks
    21
    Thanked 418 Times in 411 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Overlapping text in QStatusBar

    Hmm... maybe some one else can help you more.
    I think this is not possible with QStatusBar, without sub classing, and overwriting the layout behavior.
    ==========================signature=============== ==================
    S.O.L.I.D principles (use them!):
    https://en.wikipedia.org/wiki/SOLID_...iented_design)

    Do you write clean code? - if you are TDD'ing then maybe, if not, your not writing clean code.

  4. #4
    Join Date
    Mar 2011
    Posts
    7
    Thanks
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default Re: Overlapping text in QStatusBar

    I have some more inputs. It looks like a problem of base class QMainWindow. For the same code, Qt3 and Qt4 behaves in a different manner.

    Qt3:
    - beheaves like native windows apps. QStatusBar::addPermanentWidget really makes the widget permamanent. The user can not resize the main window in a way so that the permanent widgets are hidden.

    qt3.PNG

    Qt4:
    - On resizing certain texts of the supposed-to-permamnent-widget becomes hidden.

    qt4.PNG

    It's not recommneded to go back to Qt3. So, I need to find out how to take care of this issue in Qt4.

    I'm using the portedcanvas Qt example to single out this problem. I added a private method createStatusBar() in canvas.cpp:

    Qt Code:
    1. void Main::createStatusBar()
    2. {
    3. statusLabel = new QLabel(tr("Ready"));
    4. gridSpacingLabel = new QLabel(tr(" Grid Spacing: 20"));
    5. xPosLabel = new QLabel(tr(" X: 640 "));
    6. yPosLabel = new QLabel(tr(" Y: 640 "));
    7. widthLabel = new QLabel(tr(" Width: 640 "));
    8. heightLabel = new QLabel(tr(" Height: 480 "));
    9. unsavedDataLabel = new QLabel();
    10. QPixmap pixmap(":changes.png");
    11. unsavedDataLabel->setPixmap(pixmap);
    12.  
    13. statusBar()->addPermanentWidget(gridSpacingLabel);
    14. statusBar()->addPermanentWidget(xPosLabel);
    15. statusBar()->addPermanentWidget(yPosLabel);
    16. statusBar()->addPermanentWidget(widthLabel);
    17. statusBar()->addPermanentWidget(heightLabel);
    18. statusBar()->addPermanentWidget(unsavedDataLabel);
    19.  
    20. statusBar()->addWidget(statusLabel);
    21. statusBar()->showMessage(tr("Showing Message"));
    22. }
    To copy to clipboard, switch view to plain text mode 

    This method is called at the end of constructor. Also note the small code change to switch between Qt3 and Qt4 [ Q"3"MainWindow(parent,name,f) ]

    Qt Code:
    1. Main::Main(QGraphicsScene& c, QWidget* parent, const char* name, Qt::WindowFlags f) :
    2. Q3MainWindow(parent,name,f),
    3. //QMainWindow(parent,name,f),
    4. canvas(c)
    5. {
    6. editor = new FigureEditor(canvas,this);
    7. QMenuBar* menu = menuBar();
    8.  
    9. Q3PopupMenu* file = new Q3PopupMenu( menu );
    10. file->insertItem("&Fill canvas", this, SLOT(init()), Qt::CTRL+Qt::Key_F);
    11. file->insertItem("&Erase canvas", this, SLOT(clear()), Qt::CTRL+Qt::Key_E);
    12. file->insertItem("&New view", this, SLOT(newView()), Qt::CTRL+Qt::Key_N);
    13. file->insertSeparator();
    14. file->insertItem("&Print...", this, SLOT(print()), Qt::CTRL+Qt::Key_P);
    15. file->insertSeparator();
    16. file->insertItem("E&xit", qApp, SLOT(quit()), Qt::CTRL+Qt::Key_Q);
    17. menu->insertItem("&File", file);
    18.  
    19. Q3PopupMenu* edit = new Q3PopupMenu( menu );
    20. edit->insertItem("Add &Circle", this, SLOT(addCircle()), Qt::ALT+Qt::Key_C);
    21. edit->insertItem("Add &Hexagon", this, SLOT(addHexagon()), Qt::ALT+Qt::Key_H);
    22. edit->insertItem("Add &Polygon", this, SLOT(addPolygon()), Qt::ALT+Qt::Key_P);
    23. edit->insertItem("Add Spl&ine", this, SLOT(addSpline()), Qt::ALT+Qt::Key_I);
    24. edit->insertItem("Add &Text", this, SLOT(addText()), Qt::ALT+Qt::Key_T);
    25. edit->insertItem("Add &Line", this, SLOT(addLine()), Qt::ALT+Qt::Key_L);
    26. edit->insertItem("Add &Rectangle", this, SLOT(addRectangle()), Qt::ALT+Qt::Key_R);
    27. edit->insertItem("Add &Sprite", this, SLOT(addSprite()), Qt::ALT+Qt::Key_S);
    28. edit->insertItem("Create &Mesh", this, SLOT(addMesh()), Qt::ALT+Qt::Key_M );
    29. edit->insertItem("Add &Alpha-blended image", this, SLOT(addButterfly()), Qt::ALT+Qt::Key_A);
    30. menu->insertItem("&Edit", edit);
    31.  
    32. Q3PopupMenu* view = new Q3PopupMenu( menu );
    33. view->insertItem("&Enlarge", this, SLOT(enlarge()), Qt::SHIFT+Qt::CTRL+Qt::Key_Plus);
    34. view->insertItem("Shr&ink", this, SLOT(shrink()), Qt::SHIFT+Qt::CTRL+Qt::Key_Minus);
    35. view->insertSeparator();
    36. view->insertItem("&Rotate clockwise", this, SLOT(rotateClockwise()), Qt::CTRL+Qt::Key_PageDown);
    37. view->insertItem("Rotate &counterclockwise", this, SLOT(rotateCounterClockwise()), Qt::CTRL+Qt::Key_PageUp);
    38. view->insertItem("&Zoom in", this, SLOT(zoomIn()), Qt::CTRL+Qt::Key_Plus);
    39. view->insertItem("Zoom &out", this, SLOT(zoomOut()), Qt::CTRL+Qt::Key_Minus);
    40. view->insertItem("Translate left", this, SLOT(moveL()), Qt::CTRL+Qt::Key_Left);
    41. view->insertItem("Translate right", this, SLOT(moveR()), Qt::CTRL+Qt::Key_Right);
    42. view->insertItem("Translate up", this, SLOT(moveU()), Qt::CTRL+Qt::Key_Up);
    43. view->insertItem("Translate down", this, SLOT(moveD()), Qt::CTRL+Qt::Key_Down);
    44. view->insertItem("&Mirror", this, SLOT(mirror()), Qt::CTRL+Qt::Key_Home);
    45. menu->insertItem("&View", view);
    46.  
    47. menu->insertSeparator();
    48.  
    49. Q3PopupMenu* help = new Q3PopupMenu( menu );
    50. help->insertItem("&About", this, SLOT(help()), Qt::Key_F1);
    51. help->setItemChecked(dbf_id, TRUE);
    52. menu->insertItem("&Help",help);
    53.  
    54. createStatusBar();
    55.  
    56. setCentralWidget(editor);
    57.  
    58. printer = 0;
    59.  
    60. init();
    61. }
    To copy to clipboard, switch view to plain text mode 

    Anyone else? any other idea?

    Regards,
    Anirban

Similar Threads

  1. Widget Overlapping picture
    By bunjee in forum Qt Programming
    Replies: 2
    Last Post: 24th November 2009, 14:50
  2. Overlapping Widgets and the Application
    By csvivek in forum Qt Programming
    Replies: 1
    Last Post: 2nd May 2008, 16:32
  3. QGraphicsView overlapping items
    By juliarg in forum Newbie
    Replies: 1
    Last Post: 5th April 2007, 09:35
  4. overlapping QGraphicsItem problem!!
    By boss_bhat in forum Qt Programming
    Replies: 3
    Last Post: 28th January 2007, 11:36
  5. overlapping canvases
    By quickNitin in forum Newbie
    Replies: 11
    Last Post: 8th October 2006, 11:22

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.