Python Forum
PyQt4 text edit align text center
Thread Rating:
  • 3 Vote(s) - 3.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
PyQt4 text edit align text center
#1
Hi there,

Is there a way of aligning the text in a text edit widget so that it is centered? There is no way of doing this in the Designer, and I have tried:
self.textwidget.setAlignment(QtCore.Qt.AlignCenter
like it says in the docs, however it doesn't seem to work, as there is no error, but text is still left aligned. What is the correct syntax for this assuming importing done like this:
from PyQt4 import QtGui
from PyQt4 import QtCore
Thanks
Reply
#2
Did you have the close parenthesis after AlignCenter ?
Reply
#3
yes, sorry I do, just the close one.
Reply
#4
see: http://stackoverflow.com/questions/25855...-qtextedit
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Transparent window background, but not text on it muzicman0 7 2,849 Feb-02-2024, 01:28 AM
Last Post: Joically
  [Kivy] Create a function to store text fields and drop downs selection in KivyMD floxia 0 1,660 Dec-18-2022, 04:34 AM
Last Post: floxia
  [Tkinter] Updating tkinter text BliepMonster 5 5,964 Nov-28-2022, 01:42 AM
Last Post: deanhystad
  Can't change the colour of Tk button text Pilover 6 14,734 Nov-15-2022, 10:11 PM
Last Post: woooee
  [PyQt] QLineEdit Caret (Text Cursor) Transparency malonn 5 2,798 Nov-04-2022, 09:04 PM
Last Post: malonn
  [PyQt] Hover over highlighted text and open popup window DrakeSoft 2 1,510 Oct-29-2022, 04:30 PM
Last Post: DrakeSoft
  [PyQt] Determine whether text in QTableView cell is fully visible or not random_nick 0 982 Oct-27-2022, 09:29 PM
Last Post: random_nick
  [PyQt] [Solved]Change text color of one line in TextBrowser Extra 2 4,888 Aug-23-2022, 09:11 PM
Last Post: Extra
  [Tkinter] The Text in the Label widget Tkinter cuts off the Long text in the view malmustafa 4 4,854 Jun-26-2022, 06:26 PM
Last Post: menator01
  [PyQt] Determining the format attributes on text in a QTextEdit object DrakeSoft 7 3,547 Apr-18-2022, 06:40 PM
Last Post: DrakeSoft

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020