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 8 7,032 Feb-13-2025, 06:16 AM
Last Post: elonnmusk
  Trying to update label text using a grid button. Edward_ 7 1,634 Dec-18-2024, 03:05 AM
Last Post: Edward_
  [PyQt] Rotake rect, image or text at its center LavaCreeperKing 8 2,405 Oct-24-2024, 09:42 PM
Last Post: deanhystad
  [Tkinter] Text input OK on Windows, not working on linux Ota 3 1,209 Sep-19-2024, 12:02 AM
Last Post: Ota
  popup, text input with two readable buttons ethompson 7 1,991 Aug-28-2024, 03:40 AM
Last Post: deanhystad
  [PyQt] Populate QComboBox with "text" and "userData" from database. carecavoador 0 1,503 Jun-19-2024, 02:01 PM
Last Post: carecavoador
  update text variable on label with keypress knoxvilles_joker 5 7,632 May-31-2024, 02:09 PM
Last Post: menator01
  Button to +1 in text box everytime it's clicked martyloo 1 1,390 May-01-2024, 02:32 PM
Last Post: Axel_Erfurt
  [Kivy] Create a function to store text fields and drop downs selection in KivyMD floxia 0 2,745 Dec-18-2022, 04:34 AM
Last Post: floxia
  [Tkinter] Updating tkinter text BliepMonster 5 11,929 Nov-28-2022, 01:42 AM
Last Post: deanhystad

Forum Jump:

User Panel Messages

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