Skip to content
Qt 6.12 LTS is out! See what's new in the release blog
  • 145k Topics
    725k Posts
    J
    I implemented Google's suggestion, but it has no effect. Here's the interesting part of the code: QAbstractTableModel Subclass class ColDef: ''' Store column definitions for a model Still a work-in-progress ''' def __init__(self, header:str, attr:str, fmt:str, align:Qt.AlignmentFlag): self.header = header self.attr = attr self.fmt = fmt self.align = align def format(self, row) -> str: if self.attr == '': return '' val = getattr(row, self.attr) if self.fmt == 'time': if isinstance(val, dt.datetime): return val.strftime("%H:%M") else: # For now... return str(val) return None columnDefs = [ # Header Field in rowset Format Alignment # ------------------ ------------------------------ ------- --------------- ColDef('Scheduled\nStart', 'start_ts', 'time', Qt.AlignCenter), ColDef('Scheduled\nEnd', 'end_ts', 'time', Qt.AlignCenter), ColDef('Leader', '', '', Qt.AlignLeft), ColDef('Actual\nStart', '', '', Qt.AlignCenter), ColDef('Actual\nEnd', '', '', Qt.AlignCenter), ColDef('Activity', '', '', Qt.AlignCenter), ColDef('Description', 'title', '', Qt.AlignLeft), ColDef('Limit', 'registrations_limit', 'int', Qt.AlignCenter), ColDef('Reg', 'confirmed_registrations_count', 'int', Qt.AlignCenter), ColDef('Wait', 'waitlist_registration_count', 'int', Qt.AlignCenter), ] class SAEventsModel(QAbstractTableModel): def __init__(self, parent=None, * , dbEngine): super().__init__() self.dbEngine = dbEngine self.rowset = [] self.fontMetrics = None def setFontMetrics(self, font:QFont): self.fontMetrics = QFontMetrics(font) def refresh(self, d:dt.date): self.beginResetModel() with Session(self.dbEngine) as dbSession: stmt = select(DVEventSession)\ .where(DVEventSession.event_date==d)\ .order_by(DVEventSession.start_ts) self.rowset = dbSession.scalars(stmt).all() self.endResetModel() def headerData(self, section:int, orientation:Qt.Orientation, role:Qt.ItemDataRole): if orientation == Qt.Orientation.Horizontal \ and 0 <= section < len(columnDefs) \ and role == Qt.DisplayRole: return columnDefs[section].header return None def rowCount(self, _) -> int: return len(self.rowset) def columnCount(self, _) -> int: return len(columnDefs) def data(self, index:QModelIndex, role:Qt.ItemDataRole): if index.isValid(): row = index.row() col = index.column() cd = columnDefs[col] if role in (Qt.ItemDataRole.DisplayRole, Qt.ItemDataRole.EditRole): # Table is read-only, return same data for Display and Edit return cd.format(self.rowset[row]) elif role == Qt.ItemDataRole.SizeHintRole: # Recalculate the text size text = cd.format(self.rowset[row]) w = self.fontMetrics.horizontalAdvance(text) h = self.fontMetrics.height() return QSize(w+20, h+10) elif role == Qt.ItemDataRole.TextAlignmentRole: # Return the desired alignment return cd.align return None Main Window snippet self.ui is loaded from a QtCreator-generated .ui file. self.ui.guildEvents' is a QTableView` td = dt.date.today() self.ui.curDate.setText(f"{td:%B} {td.day} {td:%Y}") self.model = SAEventsModel(dbEngine=dbEngine) self.model.refresh(td) self.model.setFontMetrics(self.ui.guildEvents.font()) self.ui.guildEvents.setModel(self.model) self.ui.guildEvents.horizontalHeader().setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents) self.ui.guildEvents.setSelectionBehavior(qv.SelectionBehavior.SelectRows) Main Window Display The middle row is selected. [image: f2a96f52-114c-4da5-9f06-ac9df814d4f0.PNG]
  • Jobs, project showcases, announcements - anything that isn't directly development
    4k 23k
    4k Topics
    23k Posts
    P
    The app is out of public beta. The link to download is: https://storyserver.polywickstudio.net/downloads/ Roadmap: https://storyserver.polywickstudio.net/docs/roadmap/ Version History: https://storyserver.polywickstudio.net/docs/roadmap/briefhistory/ The software is off-line first, the databases (the application creates) is stored on your local computer. Note: links updated.
  • Everything related to designing and design tools

    133 403
    133 Topics
    403 Posts
    A
    Thanks a lot for all this information. It has helped me get clarity on the questions that have been bugging me for weeks. I can now decide better what I want to do, and why. I will definitely share these with them ideas about unifying the UI for mobile and desktop with Qt, as it seems like it doesn't necessarily warrant replacing starting their application from scratch, only their UI code will get replaced (and its bindings).
  • Everything related to the Software Quality Tools

    97 272
    97 Topics
    272 Posts
    C
    @VerEng can you try to perform the click on the actual computer, instead of through remote control? I seem to recall cases where use of remote control tools interfered with the click that is meant to pick.
  • Everything related to learning Qt.

    402 2k
    402 Topics
    2k Posts
    M
    [image: 01776ece-1308-4e3c-98fd-2749b3a4e221.png] Challenges faced: So when it came to building the d-pad, I was absolutely lost and was trying to approach this problem by drawing and arc instead and so I was reading about PathArc, and so it was getting so complicated, then I did see how it was implemented in the solution. repo: https://github.com/Meehir5907/QML-for-Beginners-Challenges/tree/Intro-Qt-Quick-My-Sol/StartingProject
  • 2k Topics
    13k Posts
    SGaistS
    Please check with the Gerrit admins if that is doable.
  • 4k Topics
    18k Posts
    JonBJ
    @lacombe said in Création de fenêtres avec des widget: return QCoreApplication::exec(); QCoreApplication Class The QCoreApplication class provides an event loop for Qt applications without UI. ? QApplication a(argc, argv); ... return a.exec();
  • This is where all the posts related to the Qt web services go. Including severe sillyness.
    1k 10k
    1k Topics
    10k Posts
    M
    I had the same “You are not authorized” error when trying to create a Jira ticket. AlexBlasche’s fix works perfectly, use the direct login URL first