Dynamic display on GUI



  • Hi,

    I would like to create on a GUI, a element to display information (like label) in two lines.

    The first message showed in lower line. When the second message arrives, it occupies the lower line, and the first message passes to upper line. When the third one arrives, it occupies the lower line, the second one passes the upper line, the first one disappears. And so forth.

    Maybe we can do this in a messagebox, but it is not embedded in a GUI.

    Does anyone have an idea, please? Thanks!


  • Moderators

    Store 2 strings in memory: topLine and bottomLine.

    When a new line is received, copy the old bottomLine into topLine, and then store the new line in bottomLine:
    @
    void recordNewLine(const QString& newLine)
    {
    topLine = bottomLine;
    bottomLine = newLine;
    }
    @

    Then, display the new topLine and bottomLine. There are many ways -- "QLabel":http://qt-project.org/doc/qt-5.0/qtwidgets/qlabel.html for example.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.