CQ5 component with class flex-wrap in edit mode - flexbox

I set div with style flex-wrap: wrap, but in edit mode, the two parsys don't side by side, but I modify wrap to nowrap, them display side by side.
But when I add this style in html page, the style is work, but it doesn't work as expected, then I modify nowrap to wrap, it doesn't work as the first image, finally, I modify wrap to nowrap again, then it works as expected.

Try setting the containers to
display: inline-block;
I used this approach when I needed to make a 2-column display where each column contained a parsys, and that sounds similar to what you want to do.

Related

disable editing in QSpinbox but enable arrows

I have a QSpinBox in which I want to enable the arrows (for up and down values) but disable inserting data by the user.
I've tried using this:
QtGui.QSpinBox.setReadOnly(True)
But it doesn't work. All is disabled and the arrows are 'stuck'.
If you set the spin-box readonly, it will disable eveything. Instead, just set the line-edit readonly, and then buttons will still work:
spinbox.lineEdit().setReadOnly(True)
you can block spinboxes editor by QtGui.QSpinBox.lineEdit().setEnabled(False).
edit: and set font color and background-color:
spinbox.lineEdit().setStyleSheet('color: black; background-color: white;')
In case someone looking for an answer for this problem in C++ come here (like me), the other answers are not straightforward because QSpinBox::lineEdit() is a protected member (so it would require to also extend the class).
What worked for me was:
auto l1SpinBox = new QSpinBox(this);
auto lineEdit = l1SpinBox->findChild<QLineEdit*>();
lineEdit->setReadOnly(true);
lineEdit->setFocusPolicy(Qt::NoFocus);
connect(l1SpinBox, static_cast<void (QSpinBox::*)(int)>(&QSpinBox::valueChanged), l1SpinBox,
[&, lineEdit](){lineEdit->deselect();}, Qt::QueuedConnection);
setReadOnly alone may do the trick for you. However in my case, I wanted to improve UI making it also not focusable, and then hiding the selection when the value changes.

How do I set a background colour for QTextBrowser?? (PyQt)

I have created a QTextBrowser and I wanted to know how i would set the background colour of the whole widget.
I have tried QTextBrowser.setBackground(QtGui.QBrush(QtCore.Qt.blue, QtCore.Qt.SolidPattern)) with no luck.
In this case I suggest you to use stylesheet:
If in QDesigner, right click on the control, click "Set Stylesheet" and write
background-color: blue;
If you want to do it by code, just use
YourControlTextBrowser.setStyleSheet("background-color: blue;")

Highlight text in textbox without modifying the markup

I was wondering if it were possible to write an extension for a browser which would change the color of text, or otherwise transform it (underline, bold, etc) without modifying the markup.
As an example:
HTML
<p>Extensions use JS, and have to modify the DOM<p>
Default Rendering
Extensions use JS, and have to modify the DOM
Desired Rendering
Extensions use JS, and have to modify the DOM
Now, I know that Extensions can modify the DOM, and to get what I wanted I could get something like:
<p>Extensions use JS, and <html:span style="font-weight: bold; font-style: italic;">have</html:span> to modify the DOM</p>
So, what I'm trying to do is NOT change the markup, at all. This would be something like the "Highlight all" functionality that you get when you're doing a "Find" on a page.
Current Solution
I found an extension which fits as a viable solution to my problem:
It's All Text!
While I would still like to have native browser highlighting, without modifying the markup, this will do fine.
You could inject CSS to make existing markup behave differently (e.g., p { font-weight:bold; } to bold all <p> elements, or .foo { background-color: green } to alter all elements with a foo class, etc.), but there is almost certainly no extension-level way to accomplish what you want. You'll have to modify the markup of the page if you want to modify arbitrary text on the page.
The only way to do what you want is to hack some low-level code and actually rewrite parts of WebKit and Gecko so that HTML is rendered differently than it should be.
I found an extension which fits as a viable solution to my problem:
It's All Text!
While I would still like to have native browser highlighting, without modifying the markup, this will do fine.
This pulls it out of the page, into an editor, and syncs them up. Works beautifully.

Text Alignment problem

How to control a running text? This is a user generated content, where user used to give with out giving space to the text. for example:
abcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefghabcdefgh
This goes beyond the specific block. Is there is a way to wrap the text? how can i control it and i also want that to be worked in ie6 also...
You can make strings with no spaces wrap by using the following CSS property:
word-wrap: break-word;
According to the MDC page on the word-wrap property, it is supported in IE 5.5+, Firefox 3.5+, and Safari 1.0+ (but not Opera).
You could use overflow:scroll; in your CSS, this would put a horizontal scroll bar. Should work in IE.

How to create a DHTML menu?

I need to create a DHTML menu with the specified features, but I can't figure out how to do it. Here's what I need:
All items are layed out horizontally. If they would be wider than the screen, two little arrows appear on the right side of the menu that allow to scroll it. Something like this:
+--------+--------+-------+---+---+
| Item 1 | Item 2 | Item 3| < | > |
+--------+--------+-------+---+---+
Menu items should be clickable anywhere in the cell. They should stretch both vertically and horizontally to the contents. The text in the items should be centered both vertically and horizontally. The menu should work in IE7/Opera/FF/Safari.
The scrolling is the easy part - I just place it all in a container (say, a <div>), set the container to overflow: hidden and then play around in Javascript with clientWidth, scrollWidth and scrollLeft. That I've figured out and have already tried.
But how to make the menu items so stretchy, clickable anywhere and centered text?
Try the CSS below:
#menu {
display: table;
}
#menu a {
display:table-cell;
vertical-align:middle;
}
And then format your menu like:
<div id="menu">
normal text
<big>large text</big>
<span style="line-height:100px;">very tall text</span>
</div>
This will force vertical alignment and prevent the links from wrapping. Let us know how it works out.
OK, I talked with my superiors and they decided that it might be OK that you cannot right-click a menu item and select "Open in New Window". If this requirement is dropped, then I'm not bound to <a> elements for links. With JavaScript I can turn anything into a link. Thus, I choose you, pikachoo <table>!
Yap, it's a heresy, but it works. More specifically, it's the only construct that I can think of that can do all of the following at the same time:
Center text horizontally and vertically;
Stretch to contents horizontally and vertically;
Not wrap to next line when items are starting to overflow.
Anything else that can do the same will probably be more convulted anyway. And before anyone has the idea - no, I don't need search engine support. It's an internal web application. It'd be pretty bad if Google could index that...
clickable anywhere is easy: you can either bind the onclick event trigger (and hopefully some cursor styling) to the atomic cell element, or you can make the atomic cell elements <a> tags (or more likely wrap these in <li>) and link and style appropriately (padding, margin, foo).
e.g. case 1:
<ul id="menu"><li class="item" onclick="foo()" style="cursor:pointer; cursor:hand; padding:1em; margin:1px; float: left;">FOO!</li></ul>
(obviously I don't really recommend inline styling or script handlers but you get the idea)
Applying padding will effectively centre the text, and having no width assigned they'll naturally stretch to fit their content.

Resources