I want to use a collapsible QLabel as a sort of console log for my app.
When it's expanded it would look like this:
And when it's collapsed it would look like this:
Is there a way to make the collapsed version to focus on the last line rather than the first line?
Related
I'm trying out both DockFX (https://github.com/RobertBColton/DockFX) and AnchorFX (https://github.com/alexbodogit) (using Clojure as the host language, in Win7 x64)
The nice thing about DockFX is that you can drag from the tabs, and set the title bar to NULL to make the pane non-draggable, but the DockingPane still allows siblings next to (which is ok), or on top of (which is not okay) the non-draggable DockNode, leaving a skinny little section of tab representing the non-draggable node when another pane is dragged on top, as shown here. This is what it looks like when a non-draggable TableView gets a TreeView dragged on top.
Question for DockFX:
How to prevent things from being dragged on top of a non-draggable DockNode, so I don't see a skinny vestigial tab?
For AnchorFX, I like how you can create substations, etc., and it feels a little snappier (actually about 1/10th the time to create a Station compared to DockFX). I modified the code so a null title removes the title bar and makes the node non-draggable.
Questions for AnchorFX:
How to prevent things from being dropped on top? (next to is okay).
How to eliminate title bar when a node is tabbed on top of other nodes?
How to drag from tab instead of title bar?
I modified the DockFX code so the popup does not appear if the DockTitleBar is null.
Inherently fixed by above.
Already works with DockFX, haven't tried fixing this with AnchorFX.
I want to create a simple GUI with PySide/PyQt.
In this GUI I want to have a raw with severeal push buttons and the length of the buttons I want to be proportional to its text label.
Looking at QPushButton and QHBoxLayout I don't see a posibility this can be done easy.
Any advice in this respect?
Thanks
Dimitar
This is easy to do with Tool Buttons. In Qt Designer:
Create the tool buttons and set the text
Put them in a horizontal layout
Add a horizontal spacer to the beginning and/or the end of the layout
Optionally, you could also:
Set a minimum width/height
Change the size-policy of the buttons to minimum/minimum
I have developed an application in Qt with QMainWindow as a main Widget, and added Mdiarea I needed for adding QMdieSubWindows.
I want know how to have a logging area like in Qt Creator.
My log text is basically what is going on. As
Started the optimizer ...
File is saved ...
The file is not loaded ...
and etc.
I thought of adding a QPlainTextEdit or a QTextEdit, and just append text to them.
I wrote this in my QMainWindow.cpp:
QPlainText* mydebugger = new QPlainText(this);
mydebugger.appendPlaintext("Debugger started");
mydebugger.show();
But this is showing the plainText over my Menu in QMainWindow;
I would like to have it on the bottom, above my StatusBar.
I would like to ask now:
QPlainTextEdit or QTextEdit: which one is better for my task? I need only appending the text, and maybe highlighting, and coloring the text.
How to get the Q(Plain)TextEdit as for example in QtCreator at the bottom with fixed position and fixed width?
I tried to create an MdiSubWindow and add the plaintext widget into it, and show it.
It works as I wanted, and I can add text in it. But I can not still make fixed at the bottom. Any ideas?
If you want colour and other formatting options, QTextEdit is your way to go. QPlainTextEdit does not allow formatting.
You're better off using a QDockWidget than a QMdiSubWindow. You can then dock your logger at the bottom of your main window.
I have a QTreeView on my window and I want to set the following behaviour: columns width must be set to resize to contents, which I have done like this:
tabla->header()->setResizeMode(QHeaderView::ResizeToContents);
Now, what I need to do is set rows to only 1 line, so, if a column contains '\n', they should not be displayed (I have a detailed description dialog to see that).
To sum up, I need to set something like "no multiline" on my treeview.
Any help would be appreciated.
I'd rather not extend qtreeview, since I have a lot of thems and wouldn't like to change them all, but if that's what it takes...
QTreeView seems to ignore the newlines in contents when uniformRowHeights is true (seen with Qt-4.8)
This not documented, so normally it shouldn't be relied upon. It would be best to remove the newlines or replace them with spaces when populating the treeview.
Also, I've noticed an exception: if there is only one row in the treeview and it contains a newline, then it gets displayed in two lines, regardless of uniformRowHeights.
For example, we have a QLabel with MaximumWidth set to 400.
When we try to display some text with pixel width more than 400, it's shown cut off.
Is there any way to make QLabel display this string in multiple lines without using QFontMetrics or the like?
If I understood your question correctly, you should use the setWordWrap function for your label, with true as its parameter.
QLabel lbl("long long string");
lbl.setWordWrap(true);
In order to show multiple lines in QLabel, right click on QLabel and select 'change rich text'. This brings up dialog where you can type the text as you want to see including enter key. Setting the word wrap is not required for this.
If you set the word wrap as well (in QLabel properties) than it will wrap each individual line in the Qlabel if it was longer than the real estate.
As another option to wrap text using Qt Designer, you can check the box under Property Editor for a QLabel: