The Following User Says Thank You to RobbieThe1st For This Useful Post: | ||
![]() |
2010-10-09
, 09:18
|
|
Posts: 3,203 |
Thanked: 1,391 times |
Joined on Nov 2009
@ Worthing, England
|
#2
|
self.textBrowser = QtGui.QTextBrowser(self.tab_4) self.textBrowser.setGeometry(QtCore.QRect(0, 10, 781, 301)) self.textBrowser.setOpenExternalLinks(True) fsock = os.popen('cat /home/opt/healthcheck/about.txt').read() self.textBrowser.setHtml(fsock) # self.textBrowser.setText (fsock) # Make the font small!!! font = QtGui.QFont() font.setPointSize(20)
def mouseMoveEvent(self, event): self.mousePressPos = QtCore.QPoint(event.pos()) if self.mousePressPos.isNull(): event.ignore() return self.x = self.mousePressPos.x() self.y = self.mousePressPos.y() event.accept() self.update()
import sys from PyQt4.QtCore import Qt from PyQt4.QtGui import * class TableWidget(QTableWidget): def __init__(self, parent = None): QTableWidget.__init__(self, parent) def contextMenuEvent(self, event): menu = QMenu(self) quitAction = menu.addAction("Quit") action = menu.exec_(self.mapToGlobal(event.pos())) if action == quitAction: qApp.quit() app = QApplication([]) tableWidget = TableWidget() tableWidget.show() sys.exit(app.exec_())
The Following 5 Users Say Thank You to noobmonkey For This Useful Post: | ||
![]() |
2010-10-09
, 10:17
|
Posts: 842 |
Thanked: 1,197 times |
Joined on May 2010
|
#3
|
The Following User Says Thank You to RobbieThe1st For This Useful Post: | ||
![]() |
2010-10-09
, 11:24
|
|
Posts: 3,203 |
Thanked: 1,391 times |
Joined on Nov 2009
@ Worthing, England
|
#4
|
@noobmonkey:
Thanks.
1. Yea, I have QTextBrowser code working, but I'm not sure it will let me do what I want(especially #2).
2. Thing is, some comics and images look fine scaled down to the resolution of the screen. Some don't.
I intend to have an back-end option that will allow the user to select between scrolling(full-size) and scaled to the screen-size.
Making it match the width, that's easily done. Its getting access to a function that allows me to scale the image onscreen to whatever dimensions I choose that's the issue. More importantly, I need to be able to scale the image [i]using a good[/url] scaling algorithm, just like with the image viewer. Nearest-neighbor etc. just won't do.
Now, last I checked, I could add a pixel-width to the img in the HTML code I'm sending to QTextBrowser, but I'm not sure I could externally change it without reloading the whole code etc. This may be the best option, but I'm really wondering if there's a better widget.
With 3, thanks for that. However, do you know of any -manual- rotation function? I'd like to be able to lock it in portrait mode based on a setting or two.
4. Alright, but there's got to be some sort of library for doing this; it seems kludgy to simply poll the cursor whenever the mouse "button" is down, and then try to extrapolate motion from that.
5. Yes, that's what I mean - I'm just slightly worried about content inside the QTextView(etc) overriding my menu - I'm trying to make the menu appear anywhere, not just where there's no image.
6. Alright, I'll see what I can do...
QRect screenGeometry = QApplication::desktop()->screenGeometry(); if (screenGeometry.width() > screenGeometry.height()) label->setText("<p align=\"center\">In Landscape Mode</p>"); else label->setText("<p align=\"center\">In Portrait Mode</p>");
Now, what I'd like to end up with is similar to the built-in image viewer(at least, the actual "show image" part), but with some differences.
I'm looking at:
1. Displaying an image with some text below it. Currently I'm using QTextBrowser, which seems to do the job.
2. Scaling of both text and image. I just need to be able to either set a % or get the current width and be able to set a pixel #.
2.5. Relatedly, I need to figure out how to get button presses of the zoom/volume keys.
3. Having portrait mode support(at least manually, through a setting).
4. Being able to slide your finger on the touchscreen to switch between images(Like how the built-in viewer does it).
5. long-press/right-click menu for whatever I end up using as my image/text viewer. How can I set this up?
6. Some sort of "multi-page" interface, like the image-viewer: You can click the "back" button in the upper right-hand corner to view another page(in that case, a list of images). In my case, it will be a QTreeWidget object.
Can you guys point me to some pages, tutorials and or code-snippets that might help me with these things?
Thanks,
-RobbieThe1st