Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6548531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:58:55+00:00 2026-05-25T11:58:55+00:00

I am using PyQT4 to create a sample application for a prospective client. I

  • 0

I am using PyQT4 to create a sample application for a prospective client. I am looking for some way to put a border around a specific widget. Please give me some pointers to look for.

updated :

class CentralWidget(QtGui.QWidget):

    def __init__(self, mainWindow):
        super(CentralWidget, self).__init__()

        self.create(mainWindow)

Above code defines the widget.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T11:58:55+00:00Added an answer on May 25, 2026 at 11:58 am

    According to the stylesheet documentation, QWidget does not support the border property (but it seems to have changed since this answer was originally published, in 2011).

    If your widget is a container of other widgets, then you should use QFrame, as it will allow you to call setFrameStyle and setLineWidth. It is preferable over calling setStyleSheet, since style-sheet will make all child widgets inherit the border property.

    Here it is a complete example:

    from PyQt4 import QtGui,QtCore
    
    class CentralWidget(QtGui.QFrame):
    
        def __init__(self, *args):
            super(CentralWidget, self).__init__(*args)
            # use for a non-contaner widget
            self.setStyleSheet("background-color: rgb(255,0,0); margin:5px; border:1px solid rgb(0, 255, 0); ")
            # use for a container widget
            self.setFrameStyle(QFrame.StyledPanel | QFrame.Plain)
            self.setLineWidth(1)
            
    if __name__ == '__main__':
        import sys
        app = QtGui.QApplication(sys.argv)
        mw = QtGui.QMainWindow()
        w = CentralWidget(mw)
        mw.setCentralWidget(w)
        mw.show()
        w.show()
        app.exec_()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm starting a basic application using Python and PyQt and could use some experienced
I'm developing a plugin UI for an existing application using PyQt4. The window is
What's the best way to log all of the exceptions in a pyqt4 application
I have a Python application (with GUI, using PyQt4) that gets spawned by the
I'm using PyQt to create a GUI application. In a view inherited from QTableView,
I was wondering how to create (using PyQt4) a derived QTabWidget with a check
I'm using PyQt4 to display a progress bar in my application, but I want
I am working on pyqt4 and python26 application.I created forms using qt designer (.ui
Im planing to do some GUI development using pyqt4 pykde and python3.1 on Kubuntu
I am making a music player in PyQt4, and I am using Phonon to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.