What I want is shown in the docs in the picture http://doc.qt.io/qt-4.8/qactiongroup.html#details, but I cannot figure out how to do it. I can create a separator by
QAction * separator = new QAction("This is ignored", actionGroup);
separator->setSeparator(true);
but then it is just a line. How is the "Alignment" text added to the action in the example?
Following your link, then to the "Menus" example link (where your example is excerpted from) and then to mainwindow.cpp (which is one of the source files for that example), I reach: http://doc.qt.io/qt-4.8/qt-mainwindows-menus-mainwindow-cpp.html
The last function in that source file is createMenus which contains the following:
formatMenu = editMenu->addMenu(tr("&Format"));
formatMenu->addAction(boldAct);
formatMenu->addAction(italicAct);
formatMenu->addSeparator()->setText(tr("Alignment"));
formatMenu->addAction(leftAlignAct);
formatMenu->addAction(rightAlignAct);
formatMenu->addAction(justifyAct);
formatMenu->addAction(centerAct);
formatMenu->addSeparator();
formatMenu->addAction(setLineSpacingAct);
formatMenu->addAction(setParagraphSpacingAct);
The important bit is the fourth line in: setText on the separator added by addSeparator()
This can be done using a QLabel with a QWidgetAction (e.g. in python):
label = QtGui.QLabel("<b>At least it is rich text!</b>")
label_action = QtGui.QWidgetAction(self)
label_action.setDefaultWidget(label)
menu.addAction(label_action)
Related
Since a Label in a PopupMenuItem, I thinks it can be set a pango text here.
PopupMenuItem: A PopupBaseMenuItem that displays text in a St.Label.
const item = new PopupMenu.PopupMenuItem("");
item.actor.set_size(300,150); <--- effect.
item.actor.create_pango_layout('<span foreground="blue" size="32">fname</span>'); <- not effect
item.actor.set_markup('<span foreground="blue" size="32">fname</span>'); <-- fail, but it worked in vala.
I read popupMenu.js source code before, but now I forgot the url.
You probably want to set this on the internal Clutter.Text of the PopupMenu.PopupMenuItems's St.Label:
const item = new PopupMenu.PopupMenuItem('');
item.label.clutter_text.set_markup(
'<span foreground="blue" size="32">fname</span>');
You can bookmark this link to the whole directory of GNOME Shell's UI:
https://gitlab.gnome.org/GNOME/gnome-shell/tree/main/js/ui
I'm using an editor widget to display a longchar value read from a text file. OpenEdge 11.5 ChUI on Linux.
The logic is similar to the following:
def var mytext as longchar
init "Sample Text. Sample Text. Sample Text.".
form mytext view-as editor large inner-chars 30 inner-lines 15
scrollbar-horizontal scrollbar-vertical
with frame frame1 no-labels no-box.
view frame frame1.
display mytext with frame frame1.
mytext:read-only = yes.
enable mytext with frame frame1.
wait-for end-error of mytext.
When the editor is displayed, the text in the editor widget is "highlighted" (i.e., shown in reverse video). (See screenshot below.)
Is there a way to display the text in the editor widget so that it is not "highlighted"?
I usually do something like this:
/* textedit.p
*
* a file viewer
*
*/
define variable fileName as character no-undo format "x(30)".
define variable fileBody as longchar no-undo.
fileName = "textedit.p".
file-info:file-name = fileName.
if file-info:full-pathname = ? then
do:
message "no such file:" fileName.
pause.
quit.
end.
copy-lob from file file-info:full-pathname to fileBody.
display
fileBody view-as editor inner-chars 160 inner-lines 52 large no-word-wrap
with
no-box
no-labels
color display normal prompt normal /* this changes the coloring */
.
pause.
https://documentation.progress.com/output/ua/OpenEdge_latest/index.html#page/dvref/color-phrase.html
You can also fiddle with frame and widget attributes if you prefer that sort of thing.
It is a standard QTableWidget
All cells are QTableWidgetItem.
All cells are editable/selectable
Question: How can I modify all the cells I have selected?
Possible way is to use the dialog open. So the idea is like this :
Select the items
Make a button or something to open input dialog.
Apply the value of input dialog to all selected items.
I was facing a similar problem a couple years ago and I solved it like this:
I have inherited my own view and I have reimplemented methods commitData() and mouseReleaseEvent().
commitData takes all selected indices from the selection model and calls QAbstractItemModel::setData() for all of them. Data are taken from the editor like this:
QByteArray n = editor->metaObject()->userProperty().name();
if (n.isEmpty())
n = delegate->itemEditorFactory()->valuePropertyName(model()->data(index, Qt::EditRole).userType());
if (!n.isEmpty())
{
QVariant data = editor->property(n);
for (const QModelIndex & idx : selectedIndices)
{
model()->setData(idx, data);
}
}
mouseReleaseEvent() performs three steps:
Get a current selection from the selection model.
Call original event handler (QTableWidget::mouseReleaseEvent())
Restore selection: QItemSelectionModel::select()
I'm newbie in indesign scripting stuffs.So I apologise as I couldn't post my trials.
Objective:
I have an indd document which will have figure caption,label etc. I need to copy content(figure which is editable) from other indd file to this document where related figure label exists.
For example:
sample.indd
Some text
Fig.1.1 caption
some text
I need to copy the content of figure1.indd and paste into the sample.indd document where Fig.1.1 string exists and so on. Now I'm doing it manually. But am supposed to automate this.
So, I need some hint how to acheive it using extendscript?
I have found something like below to do this, but I don't have any clue to develop it further and also am not sure whether this approach is correct to get my result. Pls help me
myDocument=app.open(File("file.indd"),false); //opening a file to get the content without showing.
myDocument.pages.item(0).textFrames.item(0).contents="some text";
//here I could set the content but I don't knw how to get the content
// ?????? Then I have to paste the content into active document.
I found the script for my requirement.
var myDoc = File("sample.indd");//Destination File
var myFigDoc = File("fig.indd");//Figure File
app.open(File(myFigDoc));
app.activeDocument.pageItems.everyItem().select();
app.copy();
app.open(File(myDoc));
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "FIG. 1.1 ";//Figure caption text
//app.findGrepPreferences.appliedParagraphStyle = "FigureCaption";//Figure Caption Style
myFinds = app.activeDocument.findGrep();
for(var i=0;i<myFinds.length;i++){
myFinds[i].insertionPoints[0].contents="\r";
myFinds[i].insertionPoints[0].select();
app.paste();
}
app.findGrepPreferences = app.changeGrepPreferences = null;
If acceptable for you, you can place an indesign file as link (place…). So a script could try to catch the "fig…" strings and do the importation.
Have a look at scripts that use finGrep() and place() command.
How to add under line under a spacebar. It is not adding space under the empty spaces.
I tried with 2-3 example and it failed to add underline under space.
1.
para = New Paragraph(New Chunk("abc. ", underlined_font))
cell = New PdfPCell(para)
cell.Border = 0
cell.BorderWidthBottom = 0
document.Add(cell)
Dim str_required_space As New String(" "c, 20)
para = New Paragraph(New Chunk(str_required_space, underlined_font))
cell = New PdfPCell(para)
cell.Border = 0
cell.BorderWidthBottom = 0
document.Add(cell)
I can't use border of cell as the length of the input string is uncertain. So I am using underline.
Please help to add spaces under space.
My Requirement image
Thanks
[Edit]
If I follow answer 1 then result would be like below
asdasd asdsad scasdnk kjashdk kasbas ckasbd ascuasc ksajcasc
asdansjdnasjakjsnasndasdmlaskdm
________________________________________________________________
But I need Below result.
asdasd asdsad scasdnk kjashdk kasbas ckasbd ascuasc ksajcasc
________________________________________________________________
asdansjdnasjakjsnasndasdmlaskdm
________________________________________________________________
I tried with Ansii Code. Not working for me :(
Dim str_required_space As New String(ChrW(32), (119 - (str_synopsis.Length Mod 119)))
para = New Paragraph(str_required_space)
cell = New PdfPCell(para)
cell.Border = 0
doc.Add(cell)
Please read chapter 2 of my book, more specifically the section about vertical position marks, separators, and tabs (section 2.2.6).
Looking at your image (ignoring the soft porn images on that site, please avoid such links in the future), I think you need a line as shown in figure 2.9 (the line under the names of the directors). The code that results in the PDF shown in that screen shot can be found here.
This is how it's done in Java:
Paragraph p = new Paragraph("abc.");
LineSeparator line = new LineSeparator(1, 100, null, Element.ALIGN_CENTER, -2);
p.add(line);
document.add(p);
It should be a no-brainer to adapt this code to C#. If you do experience problems, then you can find the ported versions of the book samples here.
What did you do wrong in your code?
This doesn't make sense:
para = New Paragraph(New Chunk("abc. ", underlined_font))
The content of the Chunk is trimmed, which explains why the spaces disappear. An alternative would be to use non-breaking space characters (ASCII code 160) instead of regular space characters (ASCII code 32).
Update
My previous answer was based on your image and it was the correct answer to your initial question. However: you have now changed your question (instead of creating a new question).
You can meet your requirement by using a page event, more specifically, by implementing the OnGenericTag() method. This method is described in chapter 5 of my book.
In Java, the implementation would look like this:
public void onGenericTag(PdfWriter writer, Document pdfDocument,
Rectangle rect, String text) {
Rectangle page = pdfDocument.getPageSize();
float x1 = page.getRight(pdfDocument.rightMargin());
float x2 = page.getLeft(pdfDocument.leftMargin());
float y = rect.getBottom() - 3;
PdfContentByte canvas = writer.getDirectContent();
canvas.moveTo(x1, y);
canvas.lineTo(x2, y);
canvas.stroke();
}
You need to create an instance of the page event with that implementation (e.g. a class that you wrote and that you named MyPageEvent) and declare that page event to the PdfWriter using the setPageEvent() method:
writer.setPageEvent(new MyPageEvent());
You can now declare you Chunk and Paragraph like this:
Chunk chunk = new Chunk(long_text);
chunk.setGenericTag("");
Paragraph p = new Paragraph(chunk);
document.add(p);
It is important that you construct your paragraph with only one Chunk object. If you have more than one Chunk in the paragraph, parts of the line will look thicker.