Skip to content

Add QSL Label Printing#993

Open
aa5sh wants to merge 4 commits intofoldynl:masterfrom
aa5sh:QSLLabels
Open

Add QSL Label Printing#993
aa5sh wants to merge 4 commits intofoldynl:masterfrom
aa5sh:QSLLabels

Conversation

@aa5sh
Copy link
Copy Markdown

@aa5sh aa5sh commented Apr 8, 2026

Adds a new Print QSL Labels dialog (QSLLabelDialog) accessible from the logbook and main menu, allowing operators to print physical QSL confirmation labels directly from the contact queue.

Features

  • Two print modes:

    • Sheet labels — supports common Avery/L7-series presets (5160, 5163, 5164, L7160, L7161) with configurable margins, spacing, rows, and columns; custom layouts also supported
    • Single/roll labels — targets dedicated label printers (e.g. Brother); auto-detects label size from the printer driver
  • Flexible content options — each section independently toggleable: DX callsign header, date/time, band/mode, RST, frequency, name/QTH, and operator "73 de" footer

  • QSO grouping — optionally groups multiple QSOs to the same callsign onto one label; groups larger than 7 QSOs split across multiple labels automatically

  • Multi-QSO table layout — grouped labels show a fixed-size table (sized for 6 rows) with column headers (Date/Time, Band/Mode, RST, Freq) so font size stays consistent across 2–6 QSOs, with blank rows filling unused space

  • Live preview — renders a scaled preview of the label in the dialog as settings change

  • PDF export — saves labels to PDF in addition to direct printing

  • Mark as sent — optionally marks printed contacts as QSL Sent (Y) after printing

  • Settings persistence — all layout and content preferences are saved and restored between sessions

image image image

aa5sh added 4 commits April 7, 2026 13:06
Introduce a new QSLLabelDialog to print/save QSL labels and integrate it into the UI.

- Added ui/QSLLabelDialog.{cpp,h,ui}: full-featured dialog with preview, presets (Avery/etc.), printer selection, sheet/single label layouts, PDF export, automatic page-size detection (Qt>=5.13), grouping of QSOs, marking contacts as QSL Sent, and settings persistence.
- Updated QLog.pro: added printsupport module and included the new source, header and form files.
- Integrated dialog into LogbookWidget: added actionPrintQSLLabel to the context menu, hooked up slot printQSLLabel(), and implemented selection -> dialog flow.
- Integrated dialog into MainWindow: added action and showPrintQSLLabels() to launch the dialog for queued ('Q') contacts.
- Use dialog->open() (window-modal) instead of exec() to avoid nested Cocoa run loops / macOS printing crashes.

These changes enable printing QSL labels from selected contacts or all queued contacts and persist user preferences for future use.
Remove grid from the printed "73 de" footer and preview line, and update single-label printing to use the printer's actual printable area (setFullPage(false)) to avoid bottom cut-off on small-label printers. Adjust renderLabel/printSingle to use the printable page rect when rendering. Large .ui changes: modernize enum/property names (scoped enums), set default tab index, add decimals properties to many QDoubleSpinBoxes, update default double values, add tooltips, refine widget alignments and preview geometry, and simplify some UI comments/ordering. In RotatorWidget, add validation for NaN/inf azimuth inputs with qWarning() and early return to avoid using invalid values.
Introduce MAX_QSOS_PER_LABEL and always reserve a fixed number of QSO rows so font sizing is computed consistently across labels. Move makeFont helper up, render a fixed number of data rows (with empty rows left blank) and apply alternating row shading to all rows. Also tweak text formatting ("To Radio" label, datetime and band/mode spacing) and refactor per-column cell rendering for clarity.
Add /build to .gitignore and remove several inline comments that referenced a macOS 26 / PrintingUI crash workaround in LogbookWidget, MainWindow, and QSLLabelDialog. No functional code changes were made; only comments were removed to clean up outdated explanations.
@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 8, 2026

Unfortunately, we both did the same thing. I have a similar solution in the upcoming 0.50. I will try to use some of your things there, but probably not until 0.51.

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 8, 2026

Ok do you want me to leave this here or just revisit it after 0.50? I'm pretty flexible on implementation so nothing here I am set on except wanting it to be slightly flexible on types of labels/printers. Other applications I've tried printing labels with it is very limiting on the printers or have to jump through so many hoops it makes it not worth the effort. I look forward to seeing what you got. Just had me thinking about QSL processing I got a big stack (for me) of cards from the Buro so was trying to make it easy to process them both in and handle replies.

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 9, 2026

Please leave it open here. I've already taken some parts

foldynl added a commit that referenced this pull request Apr 9, 2026
@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 9, 2026

BTW, you can test it - branch devel_0.50

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 9, 2026

I like the way you laid it all out and preview and all. One issue I have is with MacOS and QT there is an issue with going through the QPrintDialog. The only way I could get it to work is to print directly to the printer. That's why I had the printer combobox and did it that way. With your code the PDF works great but when I hit print it just crashes. BTW I like the way you added the debug logging in the Help Menu.

crashrpt.txt
qlog_debug_20260409085702.log

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 9, 2026

I'm not a MacOS specialist, but according to the coredump it crashed somewhere deep in the MacOS library. It went through the QT library. is it possible to try to find what is wrong?

39 QtPrintSupport 0x101ddae80 QPrintDialogPrivate::openCocoaPrintPanel(Qt::WindowModality) + 540
40 QtPrintSupport 0x101ddb444 QPrintDialog::exec() + 76

Did you have the same experience with QPrintDialog or am I doing something wrong? If it doesn't work, we'll have to make different version for MacOS (where the printer will be in the selection) and another dialog version for the rest, where QPrintDialog will be used.

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 9, 2026 via email

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 9, 2026

In a quick test this seems to work. It's a simple solution that works - no crash and printed. I would need to test with my printer and label printer at home.

print.txt

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 10, 2026

Ok it worked good with sheets of labels. It didn't with my label printer but that's not a big deal to me - for it to work would need custom paper size I think. The way it is now is great. Not sure it is worth that effort. But this change I put above prompts to select a printer then sends it no problem.

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 10, 2026

I’m sorry, but does “this seems to work” mean that it no longer crashes with your patch ?

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 10, 2026

I tried recompiling it on a colleague's Mac with MacOS26.4 and there the printer dialog appears correctly without any issue or crash without our patch. There is something strange about it.

please, could you test following patch ?

diff --git a/ui/QSLPrintLabelDialog.cpp b/ui/QSLPrintLabelDialog.cpp
index 99cdbecc..e949b8a5 100644
--- a/ui/QSLPrintLabelDialog.cpp
+++ b/ui/QSLPrintLabelDialog.cpp
@@ -815,8 +815,12 @@ void QSLPrintLabelDialog::print()
     FCT_IDENTIFICATION;
 
     QPrinter printer(QPrinter::HighResolution);
+    printer.setOutputFormat(QPrinter::NativeFormat);
+
     QPrintDialog printDialog(&printer, this);
 
+    printDialog.setOption(QAbstractPrintDialog::PrintToFile, false);
+
     if ( printDialog.exec() == QDialog::Accepted )
     {
         renderer.printAll(&printer);

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 10, 2026

With this patch it still crashes when I hit print. The code I attached above it does print to the print successfully with no crashes. Sorry for the poor choice of words but the only reason I said seems to work is I just printed to plain paper. I didn't test with a sheet of labels.

Is your colleagues Mac a silicon based Mac? In my limited research it seems that may the cause of the crash, may even depend on the version. Mine is a M4.

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 10, 2026

It is a M4 with 26.4. That doesn't make sense to me. I'll try to do some more tests on Monday.

@kyleboyle
Copy link
Copy Markdown

kyleboyle commented Apr 10, 2026

devel_0.50 - crashes
Lada's patch - crashes
Michael's patch - bypassing the problem platform library works

Apple M1 Max Sequoia 15.5 (24F74)
Qt_6_9_1_from_MacPorts_arm64

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 11, 2026

thank @kyleboyle

@aa5sh : Which version of Qt are you using?

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 11, 2026

Could you please also test whether Qt Creator crashes when you use “Print Document”? Because the only difference is that QPrinter is passed as a pointer to a dynamically allocated object in QT Creator. In QLog, it is passed as a pointer to a statically allocated object, which might play a role.

Could I ask you to test whether replacing it with
QPrinter *printer = new QPrinter(QPrinter::HighResolution);
and then passing the printer pointer improves the situation?

Please, do not call any deallocation. Just new and no delete. like this:
https://github.com/qt-creator/qt-creator/blob/51fff71372ae1247e5b5078723536847e2b0534a/src/plugins/help/helpwidget.cpp#L997

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 11, 2026 via email

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 11, 2026

I probably expressed myself poorly, but your finding is interesting as well. Otherwise, I meant whether you are able to run a print of some short text(source code) from Qt Creator. Just QTCreator uses dynamic allocation for QPrinter class.

@kyleboyle
Copy link
Copy Markdown

kyleboyle commented Apr 11, 2026

I can confirm that running outside of qt creator does NOT crash on the head of the devel branch

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 11, 2026

and are you able to print from qr creator? for example a short source code?

I want to find out why it crashes. And qt creator prints the same way as qlog with only one small difference

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 11, 2026

Ok if I just try to print some source code from QT Creator the dialog opens fine no crash. I changed that line *printer and QLog still crashes if launched from QT Creator.

@kyleboyle
Copy link
Copy Markdown

Ok if I just try to print some source code from QT Creator the dialog opens fine no crash.

Same here

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 11, 2026

thank you, unfortunately it still doesn't make sense to me. @aa5sh Michael, what version of QT are you using?

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 11, 2026 via email

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 11, 2026

image I think the reason why QT Creator can print is the same reason QLog can print at runtime outside the IDE. Still not sure why it crashes when launched from the IDE, similar to the crash I have if I click widgets wrong causing a crash in the IDE but not there in production. Never could figure that one out either.

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 12, 2026

Alright, it seems I’m currently unable to understand the issue causing the crash. I will implement what Michael suggested. Thanks for testing.

foldynl added a commit that referenced this pull request Apr 12, 2026
The issue was that launching QPrintDialog
caused the application to crash on macOS. This problem is observed
only on macOS; on other operating systems, this workaround is not present
and the native QPrintDialog is used.

The workaround adds the option to select a printer directly within the dialog,
thereby avoiding the need to invoke QPrintDialog. See more details #993.
@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 12, 2026

BTW, should be fixed in devel_0.50.

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 12, 2026 via email

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 12, 2026

Just to be sure: remove commit cef33e1 and leave it as it is?

@aa5sh
Copy link
Copy Markdown
Author

aa5sh commented Apr 12, 2026 via email

@foldynl
Copy link
Copy Markdown
Owner

foldynl commented Apr 12, 2026

It just surprises me a bit because @kyleboyle reported that all my patches crash.

@kyleboyle
Copy link
Copy Markdown

I was running everything from qt creator debug. My experience is the same as Michael's, sorry for the confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants